R

Ram Sharma • 3.40K Points
Extraordinary

Q. Which collector creates a sorted map using the natural ordering of keys?

  • (A) groupingBy() with TreeMap::new
  • (B) toMap() with TreeMap::new
  • (C) partitioningBy() with sorted()
  • (D) toSortedMap()
  • Correct Answer - Option(B)
  • Views: 4
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`toMap(..., ..., TreeMap::new)` allows sorting keys by their natural order.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.