Java String Length: How to Get It
To obtain the length of a string, you can use the length() method of the String class. Here is an example:
String str = "Hello World";
int length = str.length();
System.out.println("字符串的长度为:" + length);
The output is:
字符串的长度为:11