How to find the length of a string?

Question:
What is a good way to find the length of a sting in java?

Answer:
Use the string method length().

Code:
public class StringLength {
   public static void main(String[] args) {
 
      String str = "This is a string";
      int len = str.length();
 
      System.out.println("String: " + str);
      System.out.println("Length: " + len);
   }
}

Output:
$ java StringLength
String: This is a string
Length: 16