241
Java ConcurrentHashMap merge() Method
The merge() method of ConcurrentHashMap class merge sets If the specified key is not already associated with a (non-null) value, associates it with the given value.
Syntax
Parameter
key – key with which the specified value is to be associated
value – the value to use if absent
remappingFunction – the function to recompute a value if present
Returns
The new value associated with the specified key, or null if none
Throws
No Exception is thrown.
Example 1
Output:
{1=Java,C, 2=php,C++, 3=.net,Rubi, 5=python,Java Script}
Example 2
Output:
{1=A,F, 2=B,G, 3=C,H, 5=E,I}
Next TopicJava ConcurrentHashMap