A

Admin • 825.56K Points
Coach

Q. What does the `putIfAbsent()` method do?

  • (A) Adds a new entry regardless of presence
  • (B) Replaces old value
  • (C) Adds only if key is absent
  • (D) Throws an exception if key exists
  • Correct Answer - Option(C)
  • Views: 6
  • Filed under category Java
  • Hashtags: Java Map

Explanation by: Admin
`putIfAbsent()` adds a new entry only if the key is not already present.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.