Determining the Length of Strings

You can determine the length of a string using the length() method. The length of a string is basically the number of characters it contains.

Here is an example which prints the length of a string.

String name = "Shazam";
int length = name.length();
System.out.println(length);

The length of a string is an imoprtant value when you want to manipulate strings.