R

Ram Sharma • 3.40K Points
Extraordinary

Q. What is the correct way to collect elements into a `SortedMap`?

  • (A) Collectors.toMap(..., ..., TreeMap::new)
  • (B) Collectors.groupingBy(..., SortedMap::new)
  • (C) Collectors.toSortedMap()
  • (D) Collectors.mapping(TreeMap::new)
  • Correct Answer - Option(A)
  • Views: 1
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`Collectors.toMap()` can accept a map supplier like `TreeMap::new` for sorted maps.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.