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.
What to know first
- stream processingStream processing is the incremental processing of data items as they become available, without requiring the complete dataset to be present first.
- filteringFiltering is the selection or exclusion of data or items according to specified criteria.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- side effectA side effect is an observable change or interaction caused by a computation beyond producing its direct result, such as modifying state or interacting with the external environment.
Related concepts
- collectincludes · Collect is an operation that gathers produced values or records into a collection or other result.
- stream processingpart of · Stream processing is the incremental processing of data items as they become available, without requiring the complete dataset to be present first.
- 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.
- 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.
- 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.
Questions about terminal operation
What is terminal operation?
A terminal operation ends a stream or sequence pipeline, triggers evaluation of preceding transformations, and produces a final result or side effect.
Which Manning books explain terminal operation?
100 Java Mistakes and How to Avoid Them, Kotlin in Action, 2E and The Art of Code.
What should I know before learning terminal operation?
Manning books that teach terminal operation usually introduce stream processing, filtering, function and side effect first.
What kinds of terminal operation are there?
Kinds of terminal operation include collect, first element and print.
What is terminal operation a kind of?
Terminal operation is a kind of suspending function. A suspending function can pause and later resume execution without blocking the underlying thread.
What is terminal operation part of?
Terminal operation is part of stream processing. Stream processing is the incremental processing of data items as they become available, without requiring the complete dataset to be present first.
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.


