Share on Google+Share on Google+

java.lang.String.length()

Advertisement
java.lang.String.length(): is the Java String class method that returns the actual length of the String.

java.lang.String.length()

length() is the Java String class method that returns the actual length of the String. The length() method will always returns integer value for any given String for example...

String str = "mylength";
//length() method
int length = str.length();
System.out.println("String Length is : " + length);

the output is:

String Length is : 8

Java length method is specified in CharSequence interface and it always return the length of the characters represented by this object.

Example Codes

length() Method In Java

String Array In Java

Advertisements

Posted on: March 27, 2005 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.