关于java枚举用法遇到一点问题
publicenumweek{MON("java1"),TUE("java2"),WED("java3"),THU("java4"),FRI("java5"),SAT("...
public enum week {
MON("java1"),TUE("java2"),WED("java3"),THU("java4"),FRI("java5"),SAT("java6 & play"),SUN("play");
String shoulddo;
public void pringshoulddo(){
System.out.println(this.shoulddo);
}
week(String shoulddo){
this.shoulddo=shoulddo;
this.pringshoulddo();
}
}
public class testweek {
public static void main(String[] args) {
week day1=week.SAT;
}
}
输出结果竟然是
java1
java2
java3
java4
java5
java6 & play
play
表面看来不是应该输出SAT对应的shoulddo嘛?
为何全部都出来了? 展开
MON("java1"),TUE("java2"),WED("java3"),THU("java4"),FRI("java5"),SAT("java6 & play"),SUN("play");
String shoulddo;
public void pringshoulddo(){
System.out.println(this.shoulddo);
}
week(String shoulddo){
this.shoulddo=shoulddo;
this.pringshoulddo();
}
}
public class testweek {
public static void main(String[] args) {
week day1=week.SAT;
}
}
输出结果竟然是
java1
java2
java3
java4
java5
java6 & play
play
表面看来不是应该输出SAT对应的shoulddo嘛?
为何全部都出来了? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询