Java ConcurrentHashMap merge() MethodThe 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. SyntaxParameterkey - 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 ReturnsThe new value associated with the specified key, or null if none ThrowsNo Exception is thrown. Example 1Test it NowOutput: {1=Java,C, 2=php,C++, 3=.net,Rubi, 5=python,Java Script} Example 2Test it NowOutput: {1=A,F, 2=B,G, 3=C,H, 5=E,I}
Next TopicJava ConcurrentHashMap
|