map
Once you have a stream of elements you can transform the
elements of the stream as they flow by1 with .map
.
.map
applies a Function
to the elements of the stream
one by one and returns you a new Stream
containing the new elements.
var numbers = List.of("1", "2", "3");
Stream<Integer> numberStream = numbers.stream()
.map(Integer::parseInt); // 1, 2, 3
1
In the real life stream metaphor, this is akin to rocks getting polished by sand as they flow.