Java 8 streams allow code that is a lot more readable than old-fashioned for
loops, in most cases. However, based on my own experience and what I\'ve read, usin
There aren't big general speed differences between streams and loops; their advantages/disadvantages are problem-specific. Whether you choose one or the other should depend (mostly) on the readability the code. For some performance comparisons, see Benchmark1 and Benchmark2 where you can notice Brian Goetz's comment to one of the answers:
Your conclusion about performance, while valid, is overblown. There are plenty of cases where the stream code is faster than the iterative code, largely because per-element access costs is cheaper with streams than with plain iterators. And in many cases, the streams version inlines to something that is equivalent to the hand-written version. Of course, the devil is in the details; any given bit of code might behave differently.
Apart from that, just make sure that when you benchmark you use the JMH.