Java String length() Method
Example
Return the number of characters in a string:
String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
System.out.println(txt.length());
Definition and Usage
The length()
method returns the length of a specified string.
Note: The length of an empty string is 0.
Syntax
public int length()
Parameters
None.
Technical Details
Returns: | An int value, representing the length of the string |
---|
❮ String Methods
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.