Java ConcurrentHashMap remove() MethodThe remove() method of ConcurrentHashMap class removes the key (and its corresponding value) from this map. This method does nothing if the key is not on the map. SyntaxParameterkey - the key that needs to be removed value - value expected to be associated with the specified key Returnsthe previous value associated with key, or null if there was no mapping for key ThrowNullPointerException. Example 1Test it NowOutput: HashMap values : {k1=100, k2=200, k3=300, k4=400} New HashMap after remove : {k1=100, k3=300, k4=400} Example 2Test it NowOutput: HashMap values : {k1=100, k2=200, k3=300, k4=400} New HashMap after remove : {k1=100, k3=300, k4=400}
Next TopicJava ConcurrentHashMap
|