标签:mon test abstract 如何 his 必须 Stub rate todo
public class Demo01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//枚举类可以有构造方法,但必须是private的,它默认的也是private的。
//枚举是一个特殊类,也是方法
//int week = 8;
Week week = Week.SUN;
week.test1();
/*switch (week) {
case SUN:
System.out.println(week.str);
break;
case MON:
System.out.println(week.str);
break;
}*/
}
}
//Java中如何来描述一个星期
enum Week{
//SUN("周日"){},MON("周一"),TUE("周二"),WED("周三"),THU("周四"),FRI("周五"),SAT("周六"); //,MON,TUE,WED,THU,FRI,SAT
SUN("周日"){
@Override
public void test1() {
// TODO Auto-generated method stub
System.out.println("我是来自周日的test1");
}
},MON("周一"){
@Override
public void test1() {
// TODO Auto-generated method stub
}
};
String str;
private Week(String str){
this.str = str;
}
//枚举类也可以有抽象方法,但是枚举项必须重写该方法,比较少用,了解
public abstract void test1();
}
标签:mon test abstract 如何 his 必须 Stub rate todo
原文地址:https://www.cnblogs.com/sun-shine1229/p/8988221.html