StringJoiner was introduced in Java 8. It joins String separated by a delimiter, starting with a supplied prefix and ending with a supplied suffix.
Let us understand it by looking into the below examples.
Join Strings using only delimiter

Output:
![]()
Join String with delimiter, prefix and suffix

Output
![]()
Merging two joiners

Output

Using Collectors.joining

Output

Using String.join
The static method join of String internally uses StringJoiner.

![]()