R

Ram Sharma • 3.40K Points
Extraordinary

Q. How can you sort a stream and collect the result to a list?

  • (A) sorted().collect(Collectors.toList())
  • (B) sorted().collect(Collectors.joining())
  • (C) collect(Collectors.sorting())
  • (D) toList(sorted())
  • Correct Answer - Option(A)
  • Views: 10
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`sorted()` is an intermediate operation. Use it before collecting with `toList()`.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.