Given a Collection of Strings, how would you join them in plain Java, without using an external Library?
Given these variables:
Collection
Collectors can join Streams which is very useful if you want to filter
or map
your data.
String joined = Stream.of("Snap", "Crackle", "Pop")
.map(String::toUpperCase)
.collect(Collectors.joining(", "));
To get a Stream from a Collection, call stream() on it:
Arrays.asList("Snap", "Crackle", "Pop").stream()