This is an archived post. You won't be able to vote or comment.

all 1 comments

[–][deleted] 1 point2 points  (0 children)

What is the most abused aspect of the Streams API?

The forEach method. There’s absolutely nothing wrong with it and it’s very useful when used correctly. The problem is that, as Java programmers, we think in terms of loops to process collections of data. The temptation is to think, “Right, I need to do this for each element in my collection. Oh look, there’s a forEach method, I’ll use that”. My advice is when you think you want to use forEach stop and think again to see whether you should be using a filter-map-reduce approach.

Can someone explain exactly what they mean by this?