我要列出星期几的下一天 用枚举实理 部分代码如下package cn.itcast.day1;
public abstract class WeekDay {
private WeekDay(){}
public final static WeekDay Sun=new WeekDay(){
@Override
public WeekDay NextDay() {
return Mon;
}
};
public final static WeekDay Mon=new WeekDay(){
@Override
public WeekDay NextDay() {
return Tus;
}
};
public final static WeekDay Tus=new WeekDay(){
@Override
public WeekDay NextDay() {
return Wen;
}
};
public final static WeekDay Wen=new WeekDay(){
@Override
public WeekDay NextDay() {
return Thu;
}
};
public final static WeekDay Thu=new WeekDay(){
@Override
public WeekDay NextDay() {
return Fri;
}
};
public final static WeekDay Fri=new WeekDay(){
@Override
public WeekDay NextDay() {
return Sta;
}
};
public final static WeekDay Sta=new WeekDay(){
@Override
public WeekDay NextDay() {
return Sun;
}
};
public abstract WeekDay NextDay();
public String toString(){
return this==Mon?"Sun":"Sta";
}
}
请问toString里的方法应当怎么写
package cn.itcast.day1;
public class EnumDemo {
/**
* @param args
*/
public static void main(String[] args) {
WeekDay weekDay=WeekDay.Mon;
System.out.println(weekDay.NextDay());
}
}
请知道的大侠们告知下,小弟万分感谢 |
|