The java.util.StringJoiner Class in Java


StringJoiner is a utility class introduced in Java 8 for constructing a sequence of characters separated by a delimiter and optionally starting with a supplied prefix and ending with a supplied suffix.

Source Code

StringJoiner joiner = new StringJoiner(", ", "[", "]");
joiner.add("One").add("Two").add("Three");
System.out.println(joiner.toString()); // Outputs: [One, Two, Three]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments