The
put() method of
java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.
Syntax:
public V put(K key, V value)
Parameter: The function accepts two mandatory parameters:
- key which specifies the key with which the specified value is to be associated
- value: which specifies the value to be associated with the specified key.
Return Value: The function returns the previous value associated with the specified key. If there was no mapping for the specified key, then this method returns null.
Below programs illustrate the above method:
Program 1:
Output:
After put(): {1=1, 2=2, 3=3, 4=4, 5=5}
Program 2: