Showing posts with label Operations. Show all posts
Showing posts with label Operations. Show all posts

Friday, July 10, 2020

Java 8 Stream Intermediate Operations (Methods) Examples

1. Overview


In this tutorial, We'll learn about What are Intermediate Operations in Java 8 Stream. All these operations are in package java.util.stream.Stream.

In the last tutorial, We've discussed Java 8 Stream API and Lambda Expressions.

Java 8 Stream Intermediate Operations (Methods)

Rules:


Java 8 Stream intermediate operations return another Stream which allows you to call multiple operations in the form of a query.

Stream intermediate operations do not get executed until a terminal operation is invoked.
All Intermediate operations are lazy, so they’re not executed until a result of processing is actually needed.

Traversal of the Stream does not begin until the terminal operation of the pipeline is executed.

Stream Intermediate Operations:

Here is the list of all Stream intermediate operations:
filter()
map()
flatMap()
distinct()
sorted()
peek()
limit()
skip()