StringJoiner is a new class in Java 8 that can be used to create a String. It can construct a sequence of characters separated by a delimiter. It can also optionally add a prefix and suffix to this sequence. We can use this sequence to get a String.
The String “[One:Two:Three]” may be constructed as follows:
StringJoiner sj = new StringJoiner(“:”, “[“, “]”);
String desiredString = sj.toString();