Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapClearExample2 { // create an enum public enum Days { Monday, Tuesday, Wednesday, Thursday }; public static void main(String[] args) { //create and populate enum map EnumMap
map= new EnumMap
(Days.class); map.put(Days.Monday,"1"); map.put(Days.Tuesday,"2"); map.put(Days.Wednesday,"3"); map.put(Days.Thursday,"4"); // print the map System.out.println("Values in map before removing:\n"+map); //clear the mapping map.clear(); //print the map again System.out.println("Values in map after removing:\n"+map); } }
Output