How to find length of a String in Java?

To find length of a String in Java, do this: string.length().

Here's how you do it:

String string = "Hello World!";

System.out.println(string.length()); // 12