A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

我在学习用普通类模拟枚举的实现原理中,对于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";
   }
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马