Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

{1=Java,C, 2=php,C++, 3=.net,Rubi, 5=python,Java Script}

Example 2

Test it Now

Output:

{1=A,F, 2=B,G, 3=C,H, 5=E,I}





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA