R

Ram Sharma • 3.40K Points
Extraordinary

Q. What does the `filter()` method do in Java Streams?

  • (A) Sorts the elements
  • (B) Removes duplicate elements
  • (C) Filters elements based on a predicate
  • (D) Maps elements to new values
  • Correct Answer - Option(C)
  • Views: 9
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`filter()` is used to include only elements that match a given predicate.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.