The length() of StringJoiner is used to find out the length of the StringJoiner in characters. It returns the length of the String representation of this StringJoiner. Note that if no add methods have been called, then the length of the String representation (either prefix + suffix or emptyValue) will be returned. The value should be equivalent to toString().length().
public int length()
Returns: This method returns the length of the current value of StringJoiner
Below programs illustrate the length() method:
Example 1: To demonstrate length() with delimeter ” ”
StringJoiner: Geeks for Geeks 15
Example 2: To demonstrate length() with delimeter “, ”
StringJoiner: Geeks, for, Geeks, A, Computer, Portal 38
- StringJoiner add() method in Java
- StringJoiner merge() method in Java
- StringJoiner toString() method in Java
- StringJoiner setEmptyValue() method in Java
- Java.util.StringJoiner in Java8
- Month length() method in Java
- AtomicLongArray length() method in Java with Examples
- AtomicIntegerArray length() method in Java with Examples
- AtomicReferenceArray length() method in Java with Examples
- File length() method in Java with Examples
- BitSet length() Method in Java with Examples
- Year length() method in Java with Examples
- When to use StringJoiner over StringBuilder?
- length vs length() in Java
- StringBuilder length() in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.