EnumMap remove() Method in Java Last Updated : 13 Jul, 2018 Comments Improve Suggest changes Like Article Like Report The Java.util.EnumMap.remove(key) method in Java is used to remove the specified key from the map. Syntax: remove(Object key) Parameters: The method takes one parameter key which refers to the key whose mapping is to be removed. Return Value: The method does not return any value. Below programs illustrate the working of remove(key) function: Program 1: Java // Java program to demonstrate remove() import java.util.*; // An enum of geeksforgeeks public enum gfg { India_today, United_States_today } ; class Enum_demo { public static void main(String[] args) { EnumMap<gfg, String> mp = new EnumMap<gfg, String>(gfg.class); // Values are associated mp.put(gfg.India_today, "61.8%"); mp.put(gfg.United_States_today, "18.2%"); // Prints the map System.out.println("The EnumMap: " + mp); // Remove mapping of this key mp.remove(gfg.United_States_today); // Prints the final map System.out.println("Map after removal: " + mp); } } Output: The EnumMap: {India_today=61.8%, United_States_today=18.2%} Map after removal: {India_today=61.8%} Program 2: Java // Java program to demonstrate the working of keySet() import java.util.*; // an enum of geeksforgeeks // rank in India and United States public enum gfg { India_today, United_States_today } ; class Enum_demo { public static void main(String[] args) { EnumMap<gfg, Integer> mp = new EnumMap<gfg, Integer>(gfg.class); // Values are associated mp.put(gfg.India_today, 69); mp.put(gfg.United_States_today, 1073); // Prints the map System.out.println("The EnumMap: " + mp); // Remove mapping of this key mp.remove(gfg.United_States_today); // Prints the final map System.out.println("Map after removal: " + mp); } } Output: The EnumMap: {India_today=69, United_States_today=1073} Map after removal: {India_today=69} Comment More infoAdvertise with us Next Article EnumMap clone() Method in Java A akash1295 Follow Improve Article Tags : Java Java-Collections Java-Functions Java-EnumMap Practice Tags : JavaJava-Collections Similar Reads EnumMap Class in Java EnumMap is a specialized implementation of the Map interface for enumeration types. It extends AbstractMap and implements the Map interface in Java. It belongs to java.util package. A few important features of EnumMap are as follows: The EnumMap class is a member of the Java Collections Framework an 12 min read EnumMap put() Method in Java with Examples The Java.util.EnumMap.put() method in Java associates specified key-value pairs. In simple words, the put() method is used to add or modify entries in the EnumMap. If the values are repeated, the older values are replaced. Example Java // Java Program to demonstrate the usage of EnumMap import java. 4 min read EnumMap putAll(map) Method in Java The Java.util.EnumMap.putAll(map) method in Java is used to copy all the mappings from one map to a newer one. Older mappings are replaced in a newer one. Syntax: void putAll(map) Parameters: The method takes one parameter map. It is the map which is to be copied to the newer one. Return Value The m 2 min read EnumMap values() Method in Java The Java.util.EnumMap.values() method in Java is used to create a collection out of the values of the map. It basically returns a Collection view of the values in the EnumMap. Syntax: EnumMap.values() Parameters: The method does not take any argument. Return Values: The method returns the collection 2 min read EnumMap remove() Method in Java The Java.util.EnumMap.remove(key) method in Java is used to remove the specified key from the map. Syntax: remove(Object key) Parameters: The method takes one parameter key which refers to the key whose mapping is to be removed. Return Value: The method does not return any value. Below programs illu 2 min read EnumMap clone() Method in Java The Java.util.EnumMap.clone() method in Java is used to copy the mapped values of one map to another. It basically creates a shallow copy of this map. Syntax: Enum_map_2 = Enum_map_1.clone() Parameters: The method does not accept any argument. Return Value: The method returns a shallow copy of a Enu 2 min read EnumMap entrySet() Method in Java The Java.util.EnumMap.entrySet() method in Java used to create a set out of the elements contained in the EnumMap. It basically returns a set view of the enum map. Syntax: enum_map.entrySet() Parameter: The method does not take any parameters. Return Value: The method returns the set view of mapping 2 min read EnumMap clear() Method in Java with Examples The Java.util.EnumMap.clear() method in Java is used to remove all the mappings from the map. The method does not delete the map instead it just clears the map of the mappings. Syntax: enum_map.clear() Parameters: This method does not accept any argument. Return Values: This method does not return a 2 min read EnumMap equals() Method in Java with Examples The Java.util.EnumMap.equals(obj) in Java is used to compare the passed object with this EnumMap for the equality. It must be kept in mind that the object passed must be a map of the same type as the EnumMap.Syntax: boolean equals(Object obj) Parameter: The method takes one parameter obj of Object t 2 min read EnumMap size() Method in Java The Java.util.EnumMap.size() method in java is used to know the size of the map or the number of elements present in the map. Syntax: Enum_Map.size() Parameters: The method does not take any parameters. Return Value: The method returns the size of the map. Below programs illustrate the working of si 2 min read Like