In this article, we will see how to use length method of String class in Java.
In Java, Strings, we can use length method to return size of given String.
Lets look to our code.
String x = "abc";
System.out.println(x.length());
Lets see it in an example.
In above example, we created two String object. We used length method to return size of a string . Method returned "21".