HashMap | and LinkedHashMap CIP | Question 7

Last Updated :
Discuss
Comments

What happens when a key-value pair already exists in the Map and we use put() to add the value associated with the same key?

It adds one more key-value pair of the same key.

It adds 2 values for the same key

It throws an error

It replaces the pre-existing value.

Share your thoughts in the comments