R

Ram Sharma • 3.40K Points
Extraordinary

Q. What does `Collectors.toMap()` require to avoid duplicate key errors?

  • (A) Custom comparator
  • (B) Custom list collector
  • (C) Merge function
  • (D) Optional.ofNullable()
  • Correct Answer - Option(C)
  • Views: 13
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
When keys may duplicate, a merge function resolves collisions in `toMap()`.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.