R

Ram Sharma • 3.40K Points
Extraordinary

Q. What is required to sort a result map by key?

  • (A) Collectors.toMap(..., TreeMap::new)
  • (B) Collectors.groupingBy(TreeMap::new)
  • (C) Collectors.toCollection(TreeMap::new)
  • (D) Collectors.ordered()
  • Correct Answer - Option(A)
  • Views: 7
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
Use `toMap()` with `TreeMap::new` as the map supplier to get a sorted result.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.