java tutorial - Java Strings length() method - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java strings length - Java examples - Java programs
Description
The length () method — The length () method returns the length of a string in Java. The length is equal to the number of 16-bit Unicode characters in the string.
Syntax
Syntax of this method:
Options
Detailed information about the parameters:
- not.
Return value
- In Java, length () returns the length of the sequence of characters represented by this object.
Example 1: Java string length definition
Below is an example of the length () method, which will help determine the length of a string.
Output
Example 2: string length comparison
Also, using the length () method, you can not only learn the length of a string, but also compare the length of a string. Below is an example of how this can be done.