This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class

String

Name

length()

Examples
String str1 = "CCCP";
String str2 = "Rabbit";
int l1 = str1.length();
int l2 = str2.length();
println(l1 + ":" + l2);  // Prints "4:6"
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.
Syntax
str.length()
Parameters
str String: any variable of type String
Updated on January 1, 2021 03:38:12am EST