intermediate operation
A stream step, such as filter, map, sorted or distinct, that returns another stream and does no work until a terminal operation runs.
In more detail
filter keeps elements that match a condition and map transforms each element. Because they are lazy, building a long pipeline costs nothing until the result is requested. Some intermediate operations, such as sorted and distinct, must remember elements and so hold state.
Examples
.filter(User::active).map(User::name)Related terms
- Stream API — The standard-library toolkit for describing a sequence of data-processing steps, such as filter, map and collect, over a source like a list.
- terminal operation — The final stream step, such as toList, collect, count or anyMatch, that starts the pipeline and produces a result.
- lazy evaluation — Postponing work until its result is actually needed, rather than doing it all in advance.
- stateful operation — A stream operation such as sorted or distinct that must remember elements it has seen before it can pass results on.
- flatMap — An operation that turns each element into a stream, or an Optional, and joins the results into one flat stream, removing a level of nesting.
Taught in
- The Streams API — Modern Java: Virtual Threads & High-Throughput Services
- Advanced Stream Operations — Modern Java: Virtual Threads & High-Throughput Services
- Stream Pipelines, Primitive Streams And Optional — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Lambdas And Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Concurrent Collections And Parallel Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep