R

Ram Sharma • 3.40K Points
Extraordinary

Q. Which of the following will result in an immutable map?

  • (A) groupingBy()
  • (B) toMap(..., ..., ..., Map::of)
  • (C) toMap(..., ..., mergeFn, Map::copyOf)
  • (D) toMap(..., ..., mergeFn, Collectors.toUnmodifiableMap())
  • Correct Answer - Option(C)
  • Views: 14
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma
Using `Map::copyOf` or `Collections.unmodifiableMap` ensures immutability.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.