String Method: String length() is used to calculate length of string.
/* Example of Simple String class using String length() method */
class HB4
{
public static void main(String args[])
{
byte a[]={'H','e','e','r','a'};
String H1=new String(a);
System.out.println(H1.length());
}
}
Sample Output