Length of String in Java - Find String Length in Java with length()

Length of String in Java: Determining the length of String in Java is much easier than what you think of. It is as easy as it is just away from a simple method length() in the java.lang.String class.

class JavaStringLength
public static void main(String args[])
// Create a string
String st="Length of string in Java is easy with length()";

// Find length of string
int stlen=st.length();

// Print the string

// Print length
System.out.println("Length is "+stlen);

st.length(): A method in the java.lang.String class that returns an int value which is length of the string.


Length of string in Java is easy with length()
Length is 46

Posted by at on

Tags: java.lang, String Handling,