String Length in JAVA programming


package SolveProblem;

import java.util.Scanner;

public class StringLength {

    public static void main(String[] args) {
        Scanner myScanner=new Scanner(System.in);
       
        String name=new String();
        System.out.println("Enter the string : ");
        name=myScanner.nextLine();
       
        int ln=name.length();
       
        System.out.println("Length of the given string is : "+ln);
    }

}

//Enter the string :
//Alamgir Hossain
//Length of the given string is : 15

No comments:

Post a Comment