Skip to main content
PreparationZone Logo
PrepZone

Stream Pipeline Basics

Lazy intermediates, terminal operations, and why elements flow one at a time.

Pass checkpoint below

Why this matters

  • Laziness explains why filter before map matters, why findFirst can stop early, and why a pipeline with no terminal does nothing.
  • This cell is the foundation — collectors, parallelism, and gatherers build on it in the next lessons.
Sourcelist.stream()
filterKeep some
mapTransform each
collectTerminal — runs everything
Nothing runs until the terminal operation. The intermediate steps only describe the work, which is why a pipeline without collect() or forEach() does nothing at all.
Java
Loading compiler…

Three properties that follow from laziness

  • Nothing runs without a terminal operation.
  • Elements flow one at a time through every stage — not stage-by-stage batching.
  • Short-circuiting (findFirst, anyMatch, limit) stops as soon as the answer is known.
Java
Loading compiler…

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 1 section

  • Creating streams

Test yourself

Answer these before moving on — recall is what makes it stick.