R

Ram Sharma • 3.40K Points
Extraordinary

Q. Which collector would be best to collect elements into a `TreeSet`?

  • (A) Collectors.toSet()
  • (B) Collectors.toTreeSet()
  • (C) Collectors.toCollection(TreeSet::new)
  • (D) Collectors.groupingBy(TreeSet::new)
  • Correct Answer - Option(C)
  • Views: 10
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
`Collectors.toCollection(TreeSet::new)` is used to collect elements into a TreeSet.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.