Removes the entry for the specified key only if it is currently mapped to the specified value.
key | key with which the specified value is associated | |
value | value expected to be associated with the specified key |
true if the value was removed
UnsupportedOperationException | if the remove operation
is not supported by this map
(optional) | |
ClassCastException | if the key or value is of an inappropriate type for this map (optional) | |
NullPointerException | if the specified key or value is null, and this map does not permit null keys or values (optional) |
@implSpec
The default implementation is equivalent to, for this map:
if (map.containsKey(key) && Objects.equals(map.get(key), value)) {
map.remove(key);
return true;
else
return false;
}
The default implementation makes no guarantees about synchronization
or atomicity properties of this method. Any implementation providing
atomicity guarantees must override this method and document its
concurrency properties.
Diagram: Map Simple