I have quickly read over the Java8 String api documentation.
Now I am little curious about String.join() method to concat/join strings.
This kind of example
We can use StringJoiner (Java8+)
import java.util.StringJoiner;
public class StringJoinerTest {
public static final String FILESEPARATOR = ", ";
public static void main(String[] args) {
StringJoiner sj = new StringJoiner(FILESEPARATOR);
sj.add("Test1");
sj.add("Test2");
sj.add("Test3");
System.out.println(sj);
}
}
Output is
Test1, Test2, Test3