In this recipe you learnt how to use three methods to process all the elements of a stream and apply an action to them. These methods are:
- forEach(): This is a terminal operation that applies an action to all the elements of Stream and returns a void value. It receives as parameter the action to apply to the elements defined as a lambda expression or as an implementation of the Consumer interface. There's no guarantee about the order in which the action will be applied to the elements of a parallel stream.
- forEachOrdered(): This is a terminal operation that applies an action to all the elements of Stream in the order of the stream, if the stream is an ordered stream, and returns a void value. You can use this method after ...