Reference+
Name
length()
Class
String
Description
Returns the total number of characters included in the String as an integer number.
People are often confused by the use of length() to get the size of a String and length to get the size of an array. Notice the absence of the parentheses when working with arrays.
Examples
String str1 = "CCCP"; String str2 = "Rabbit"; int l1 = str1.length(); int l2 = str2.length(); println(l1 + ":" + l2); // Prints "4:6"
Syntax
str.length()
Parameters
str
String: any variable of type String
Return
int
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.