EnumMap.keySet() has the following syntax.
public Set <K> keySet()
In the following code shows how to use EnumMap.keySet() method.
// ww w .ja v a 2 s . c o m import java.util.*; enum Tutorial { CSS, Python, PHP, Java, Javascript }; public class Main { public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String> (Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map); // create a new set and return the set view of the keys contained Set<Tutorial> set = map.keySet(); System.out.println("Set: " + set); } }
The code above generates the following result.