liveBook · Manning

Terminal operation

As explained in The Art of Code

A terminal operation ends a pipeline, triggers its deferred processing, and produces or materializes a final result.

A terminal operation is the deliberate stopping point of a functional pipeline: it triggers deferred processing and materializes the final result. Without it, stream creation, filtering, and mapping describe behavior but process no data. section 6.3.1 section 6.5

Use terminal operations as the pipeline’s final action:

  • Choose one terminal operation after any number of intermediate operations, including none. section 6.3.1
  • Expect execution to begin only when operations such as toList, collect, or count are applied. section 6.5
  • Treat the consumed pipeline as finished; it cannot be reused after termination. section 6.3.1

Materializing recent authors

A stream can filter recently published books and map them to author names, but the result becomes a List only at the final toList() call. The terminal operation turns a readable transformation description into executed output. section 6.3.1

How The Art of Code covers it

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 it assumes
Assumes familiarity with pipelines and transformations while relating terminal operations to streams, lambdas, and functional interfaces.
What you can do after
Apply it via Java Stream API to execute transformations and obtain a final collection or aggregate.
How it connects
Connects terminal operations with functional pipelines, streams, intermediate operations, lazy evaluation, lambdas, and functional interfaces.

Also explained in

Compare how 3 books explain terminal operation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.