JavaEnum

public class WeekDay {
    private WeekDay(){}    

    public final static WeekDay  SUN = new WeekDay();

    public final static WeekDay  MON = new WeekDay();

    public WeekDay nextDay(){
       if(this == SUN){
           return MON;
       }else{
           return SUN;
       }
    }
    @Override
    public String toString() {
        return  this == SUN?"SUN":"MON";
    }
}

public class EnumTest {
     public static void main(String[] args){
       WeekDay  w  = WeekDay.SUN;
                System.out.print(w.nextDay());
     }
}
 

你可能感兴趣的:(sun)