本帖最后由 杨洋 于 2012-7-29 17:03 编辑
public class EnumTest {
public static void main(String[] args){
WeekDay1 weekDay = WeekDay1.MON;
System.out.println(weekDay.nextDay());
WeekDay weekDay1 = WeekDay.FRI;
System.out.println(weekDay1.name());
System.out.println(weekDay1.getClass());
System.out.println(weekDay1.values().length);
System.out.println(weekDay1.valueOf("SUN").toString());
System.out.println(weekDay1.ordinal());
}
public enum WeekDay{
SUN(1),MON(1)/*在我练习的时候发现这和张老师讲的不太一样,这不添参数无法运行第二个,求证*/,THE,WED,THI,FRI,STA;
private WeekDay(){System.out.println("frist");}
private WeekDay(int day){System.out.println("second");}
}
}
不添参数运行结果
添参数后的运行结果
|