Stream: Terminal and Non-Terminal Operations in Java

The Stream interface has a selection of terminal and non-terminal operations.

Non-terminal Operations

A non-terminal stream operation is an intermediate operation which creates a new Stream by transforming or filtering the original stream.

  • filter()
  • map()
  • flatMap()
  • distinct()
  • limit()
  • peek()
Terminal Operations

A terminal stream operation is an operation that returns a result.

  • anyMatch()
  • allMatch()
  • noneMatch()
  • collect()
  • count()
  • findAny()
  • findFirst()
  • forEach()
  • min()
  • max()
  • reduce()
  • toArray()

Related Articles:

Leave a Reply

Your email address will not be published. Required fields are marked *