What does the filter() method do in a Stream?

  1. Filters based on a condition
  2. Sorts the stream
  3. Transforms data
  4. Reduces the stream
Correct answer Filters based on a condition

Explanation

filter() is used to retain elements that match a given predicate.

Update: Admin added a tag on this question

Topics

By Admin · · 29 views