Java EnumMap remove() method
Last Updated : 17 Mar 2025
The remove() method of Java EnumMap class is used to remove the mapping for the given key from EnumMap if the given key is present.
Syntax
Parameters
key - the key whose mapping is to be removed from the map.
Returns
This method returns the old value associated with the given key or null if there was no mapping for the given key.
Exception
NA
Example 1
Output:
Map: {Java=1, CSS=2, Python=3, Android=4}
Updated Map: {Java=1, Python=3, Android=4}
Example 2
Output:
Map: {Monday=1, Tuesday=2, Wednesday=3}
Updated Map: {Monday=1, Tuesday=2, Wednesday=3}