Skip to main content


Showing posts with the label Streams

Java 8 - Streams in Action

In this post, we will cover following topics. What are Streams? What is a pipeline? Key points to remember for Streams. How to create Streams? What are Streams? Java 8 introduced new package which contains classes to perform SQL-like operations on elements. Stream is a sequence of elements on which you can perform aggregate operations (reduction, filtering, mapping, average, min, max etc.). It is not a data structure that stores elements like collection but carries values often lazily computed from source through pipeline . What is a pipeline? A pipeline is sequence of aggregate (reduction and terminal) operations on the source. It has following components. A source: Collections, Generator Function, array, I/O channel etc. zero or more intermediate operations: filter, map, sequential, sorted, distinct, limit, flatMap, parallel etc. Intermediate operations returns/produces stream. a termination operation: forEach, reduction, noneMatch, allMatch, c