Sometimes you want to filter a Stream with more than one condition:

myList.stream().filter(x -> x.size() > 10).filter(x -> x.isCool()) ...

or you could do the same with a complex condition and a single filter:

myList.stream().filter(x -> x.size() > 10 && x -> x.isCool()) ...

My guess is that the second approach has better performance characteristics, but I don’t know it.

The first approach wins in readability, but what is better for the performance?

4 Answers
4

Leave a Reply

Your email address will not be published. Required fields are marked *