Java StringBuilder length() Method
Example
Return the number of characters in a StringBuilder:
StringBuilder sb = new StringBuilder("Hello");
System.out.println(sb.length());
Definition and Usage
The length() method returns the number of characters in a StringBuilder.
Tip: The length is not the same as the capacity.
Syntax
public int length()
Parameter Values
None.
Technical Details
| Returns: | An int value, representing the number of characters. |
|---|
Related Pages
❮ StringBuilder Methods