liveBook · Manning

Terminal operation

A terminal operation ends a stream or sequence pipeline, triggers evaluation of preceding transformations, and produces a final result or side effect.

How 3 Manning books explain it

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.

Read how Kotlin in Action, 2E explains terminal operation →

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.

Read how The Art of Code explains terminal operation →

Related concepts

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.