我在学习用普通类模拟枚举的实现原理中,对于toString的return返回值的编写上遇到了困难,不知道怎么写?我写的这个toString的return返回值是不对的,求大神指导,帮我完成对return的返回值编写。
public abstract class WeekDay{
private WeekDay(){}
public static final WeekDay SUN = new WeekDay(){
public WeekDay nextDay(){return MON;}
};
public static final WeekDay MON = new WeekDay(){
public WeekDay nextDay(){return TUE;}
};
public static final WeekDay TUE = new WeekDay(){
public WeekDay nextDay(){return WED;}
};
public static final WeekDay WED = new WeekDay(){
public WeekDay nextDay(){return THU;}
};
public static final WeekDay THU = new WeekDay(){
public WeekDay nextDay(){return FRI;}
};
public static final WeekDay FRI = new WeekDay(){
public WeekDay nextDay(){return WED;}
};
public static final WeekDay SAT = new WeekDay(){
public WeekDay nextDay(){return SUN;}
};
public abstract WeekDay nextDay();
public String toString(){
return this == SUN? "SUN":"MON";
}
}
|
|