Java EnumMap remove() methodThe remove() method of Java EnumMap class is used to remove the mapping for the given key from EnumMap if the given key is present. SyntaxParameterskey - the key whose mapping is to be removed from the map. ReturnsThis method returns the old value associated with the given key or null if there was no mapping for the given key. ExceptionNA Example 1Test it NowOutput: Map: {Java=1, CSS=2, Python=3, Android=4} Updated Map: {Java=1, Python=3, Android=4} Example 2Test it NowOutput: Map: {Monday=1, Tuesday=2, Wednesday=3} Updated Map: {Monday=1, Tuesday=2, Wednesday=3}
Next TopicJava EnumMap
|