Skip to content

Instantly share code, notes, and snippets.

@omernaci
Last active April 9, 2023 21:27
Show Gist options
  • Save omernaci/59a873b31c918a10ef06ebf7478209dc to your computer and use it in GitHub Desktop.
Save omernaci/59a873b31c918a10ef06ebf7478209dc to your computer and use it in GitHub Desktop.
Java Stream Intermediate Operations
Operation Type Description
filter Stateless Returns a new stream consisting of elements that match the given predicate.
map Stateless Returns a new stream consisting of the results of applying the given function to the elements of this stream.
flatMap Stateless Returns a new stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
sorted Stateful Returns a stream consisting of the elements of this stream sorted according to the provided Comparator.
peek Stateless Returns a stream consisting of the elements of this stream additionally performing the provided action on each element as elements are consumed from the resulting stream.
limit Stateless Returns a stream consisting of the elements of this stream truncated to be no longer than the specified maximum size.
skip Stateless Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment