Javatpoint Logo
Javatpoint Logo

Java EnumMap remove() method

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

Test it Now

Output:

Map: {Java=1, CSS=2, Python=3, Android=4}
Updated Map: {Java=1, Python=3, Android=4}

Example 2

Test it Now

Output:

Map: {Monday=1, Tuesday=2, Wednesday=3}
Updated Map: {Monday=1, Tuesday=2, Wednesday=3}
Next TopicJava EnumMap



Help Others, Please Share

facebook twitter pinterest