Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapKeySetExample1 { // create an enum public enum Tutorial { CSS, Python, PHP, Java, Javascript }; public static void main(String[] args) { //create and populate enum map EnumMap
map = new EnumMap
(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); //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