length() method of String class is used to count the number of characters of invoking String object. It returns the length of string.
public static void main (String arg[ ])
String s1 = “Code project”;
int l = s1.length();
output :- Length=12