package cn.itcast.interview;
public class EnumTest {
public static void main(String[]args)
{
// System.out.println(weekday.MON.nextDay());
week s=week.SSS;
//System.out.print(s);
//System.out.print(s.getClass());
//System.out.print(s.ordinal());
//System.out.print(s.ordinal());
//System.out.print(week.valueOf("SSS"));//将传来的字符串变为枚举类里的元素(当然此枚举类里必须有这个元素)
}
public enum week{
SSS(1),DDD;
week(){System.out.print("first");}
week(int a){System.out.print("second");}
} //每一个元素的类型都是week 每一个元素都是调用匿名内部类生成的
}
为什么得到的结果是:是firstsecond 即:week s=week.sss; 两个构造函数都用到了
|