Java EnumMap.entrySet()
Syntax
EnumMap.entrySet() has the following syntax.
public Set <Map.Entry <K, V>> entrySet()
Example
In the following code shows how to use EnumMap.entrySet() method.
// ww w. j a va 2 s .com
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);
Set<Map.Entry<Tutorial, String> > set = map.entrySet();
System.out.println("Set: " + set);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »