A

Admin • 828.70K Points
Coach

Q. Which method replaces the value for a key only if it is already mapped?

  • (A) putIfAbsent()
  • (B) replace()
  • (C) updateIfPresent()
  • (D) setIfPresent()
  • Correct Answer - Option(B)
  • Views: 10
  • Filed under category Java
  • Hashtags: Java Map

Explanation by: Admin
`replace(key, value)` only works if the key is already present in the Map.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.