How to flatmap a stream of streams in Java? [duplicate]

Solution 1:

Basically, you want to concatenate all the nested streams into one flat stream, without affecting the members themselves. You'll use

objectStreams.flatMap(Function.identity());

because you must provide some mapping function for each stream member, and in this case it is the identity function.