Terminal operation
A terminal operation ends a stream or sequence pipeline, triggers evaluation of preceding transformations, and produces a final result or side effect.
100 Java Mistakes and How to Avoid Them
A terminal operation is a stream operation that triggers evaluation of a Java stream pipeline and produces a final result or side effect.
- How it is used
- Triggers Stream pipeline evaluation to obtain a result rather than leave filtering or sorting unevaluated.
- How deep it goes
- Defines pipeline execution and examines laziness, side-effect risks, and single-consumption failures without Stream implementation internals.
- Examples
- Uses filtering empty strings, partitioning strings by a substring, counting before anyMatch(), and reusing a stream in a loop.
- What you can do after
- Diagnose/debug with it by recognizing unevaluated pipelines and streams consumed before a later operation.
Read how 100 Java Mistakes and How to Avoid Them explains terminal operation →
Kotlin in Action, 2E
A terminal operation is a sequence operation that produces a final result and triggers evaluation of the preceding transformations.
- How it is used
- Triggers lazy sequence pipelines and cold flow pipelines when a result, collection, subscription, or side effect is required.
- How deep it goes
- Explains deferred evaluation, element-by-element processing, early stopping, suspension, cancellation, and sequence performance trade-offs.
- Examples
- Uses squared numbers with `toList` and `find`, natural-number `sum`, hidden-directory `any`, and temperature-flow `collect` or `first`.
- What you can do after
- Apply it via Kotlin sequence and Flow operators to materialize results, aggregate values, collect emissions, or stop after a needed value.
The Art of Code
A terminal operation ends a pipeline, triggers its deferred processing, and produces or materializes a final result.
- How it is used
- Ends functional pipelines by triggering deferred transformations and producing a materialized result.
- How deep it goes
- Explains laziness, execution, materialization, single-use consumption, and common operations, without detailing their internal implementations.
- Examples
- Uses Java stream pipelines that filter recent books, map authors, and terminate with toList(), alongside analogous sequence and collection examples.
- What you can do after
- Apply it via Java Stream API to execute transformations and obtain a final collection or aggregate.
Related concepts
- collectincludes · collect is an operation that consumes produced values and gathers them into a collection or other result.
- flowuses · A Flow is an asynchronous stream abstraction whose values are collected over time and whose producer may be cold, executing anew for each collection.
- first elementincludes · A first operation retrieves the initial element of a sequence or collection, optionally subject to a predicate, and indicates when no matching element exists.
- printincludes · Print is a programming operation that writes a value or its textual representation to an output destination, often standard output.
- suspending functionkind of · A suspending function can pause and later resume execution without blocking the underlying thread.
- streamingpart of · Streaming is the incremental handling of a sequence of data items, including their processing, transfer, or consumption as they become available.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


