Length of String

length() method is used to find out length of string. String class has one method length() called on string object.

Method Signature:

 public int lenth()


class len
public static void main(String arg[])
String s=new String("hello world");
String b="this is demo";

System.out.println("Length of s:"+s.length());
System.out.println("Length of b:"+b.length());
/* Output:
Length of s:11
Length of b:12