Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapKeySetExample2 { // 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"); //print the map System.out.println("Map: "+map); // create a new set and return the set view of the keys contained Set
set = map.keySet(); // print the map again System.out.println("KeySet: "+set); } }
Output