Java String length()

The length() method returns the number of characters in a string.

Example


length() Syntax

The syntax of the string's length() method is:

string.length()

length() Arguments

  • The length() method doesn't take any arguments.

length() Return Value

  • The length() method returns the length of a given string.

The length is equal to the number of characters (code units) in the string.


Example: Java String length()