Find The Length Of An String | Java Programs

Output:

*** Length of String ***

The String is: Hi, My name is Alee!
Its length is: 20

Click Here For Java Online Compiler

Solution:

class StringLength {

    public static void main(String[] args) {
        System.out.println("*** Length of String ***" + "\n");
        String s = "Hi, My name is Alee!";
        //length of the string
        int length = s.length();
        System.out.println("The String is: " + s);
        System.out.println("Its length is: " + length);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon