Java Streams: ForEach
Streams can be filtered, mapped, collected…
There is also the possibility to loop over the stream elements to perform some logic. All in the one-line-of-code style, typical of functional programming.
Bear with me and let’s try to perform an operation over each element of our list of users. Let’s use the .forEach()
method.