Back to JavaBack to Streams

Intermediate Operations

Learn the operations that build lazy stream pipelines.

Intermediate Operations

Intermediate operations on Java Streams return another Stream and are lazy. They form a processing pipeline that is executed only when a terminal operation is reached.

  • map: transform elements
  • filter: keep elements matching a predicate
  • flatMap: flatten nested structures
  • sorted: order stream elements
  • distinct: remove duplicates
  • limit / skip: control stream size

Since intermediate operations are lazy, they do not execute until a terminal operation such as collect or forEach is invoked.