JavaScript has Array.join()
js>[\"Bill\",\"Bob\",\"Steve\"].join(\" and \")
Bill and Bob and Steve
Does Java have anything
Java 8 does bring the
Collectors.joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
method, that is nullsafe by using prefix + suffix
for null values.
It can be used in the following manner:
String s = stringList.stream().collect(Collectors.joining(" and ", "prefix_", "_suffix"))
The Collectors.joining(CharSequence delimiter)
method just calls joining(delimiter, "", "")
internally.