package enumTest;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.Map.Entry;
interface A1 {
void isRest();
}
enum Test2 implements A1 {
MON("一", 1), TUE("二", 2), FRI("三", 3) { [@Override](https://my.oschina.net/u/1162528) public void isRest() { // TODO Auto-generated method stub System.out.println("today is " + FRI.name + "休息"); }};private String name;private int id;private Test2() {}private Test2(String name, int id) { this.name = name; this.id = id;}[@Override](https://my.oschina.net/u/1162528)public void isRest() { // TODO Auto-generated method stub}/* abstract void isOpen(); */
}
public class Test1 {
public static void main(String[] args) { // public static> EnumSet allOf(Class elementType) // 创建一个包含指定元素类型的所有元素的枚举 set。 EnumSet TestSet = EnumSet.allOf(Test2.class); for (Enum enum1 : TestSet) { System.out.println(enum1); /* * MON TUE FRI */ } EnumMap Map = new EnumMap<>(Test2.class); Map.put(Test2.TUE, "ss"); for (Iterator > iter = Map.entrySet().iterator(); iter.hasNext();) { Entry entry = iter.next(); System.out.println(entry.getKey() + ":" + entry.getValue()); }}
}