String Handling – length()

length()

 

syntax:

                       int length();

 

length() method of String class is used to count the number of characters of invoking String object. It returns the length of string.

class Example1

{

public static void main (String arg[ ])

{

String s1 = “Code project”;

int l = s1.length();

System.out.println(“Length=”+l);

}

}

     output :-  Length=12

3 thoughts on “String Handling – length()”

Leave a Reply

Your email address will not be published. Required fields are marked *