/**
*
* @author juvie
* 所有的枚举元素都是静态成员变量,在初始化时都会调用构造函数。
*/
public class EnumTest {
public enum WeekDay{
SUN(1),MON(),TUE,WED,THI,FRI,SAT;
private WeekDay(){
System.out.println("first");
}
private WeekDay(int num){
System.out.println("second");
}
}
public static void main(String[] args) {
WeekDay wk=WeekDay.SUN;
System.out.println(wk);
System.out.println(wk.name());
System.out.println(wk.ordinal());
}
}
second
first
first
first
first
first
first
SUN
SUN
0