Fastest way to iterate list in Java 8

Let's talk speed

Java performance tutorial How fast are the Java 8 streams?

#java #jax london
Speed image via Shutterstock

In this JAX Magazine sneak preview, JAX London speaker Angelika Langer answers the most important question for anyone using Java streams: are they really faster?

Java 8 came with a major addition to the JDK collection framework, namely the stream API. Similar to collections, streams represent sequences of elements. Collections support operations such as add[], remove[], and contains[] that work on a single element. Streams, in contrast, have bulk operations such as forEach[], filter[], map[], and reduce[] that access all elements in a sequence. The notion of a Java stream is inspired by functional programming languages, where the corresponding abstraction is typically called a sequence, which also has filter-map-reduce operations. Due to this similarity, Java 8 at least to some extent permits a functional programming style in addition to the object-oriented paradigm that it supported all along.