Let's map a list of words using Java 8 streams:
List<String> words = Arrays.asList("A", "bbb", "CC", "dd");
// Map the words to UPPERCASE and join them with the ":" separator
String joined = words.stream()
.map(String::toUpperCase)
.collect(Collectors.joining(":")); // "A:BBB:CC:DD"
Example of mapping Java 8 streams using the Stream#map
method.
Calling the map
method of a stream returns another stream with the mapped values. In this example the words are mapped into their uppercase versions, and the resulting stream is converted to a string by collecting all of its items and concatenating/joining them with a joining collector, using the ":"
separator.