package com.ceac.deng; public class T13Enum { public static void main(String[] args) { // TODO Auto-generated method stub WeekDay todDay = WeekDay.SAT; System.out.println(todDay + "的下一天是" + todDay.nextDay()); } } class WeekDay { public final static WeekDay SUN = new WeekDay(); public final static WeekDay MON = new WeekDay(); public final static WeekDay TUE = new WeekDay(); public final static WeekDay WED = new WeekDay(); public final static WeekDay THU = new WeekDay(); public final static WeekDay FRI = new WeekDay(); public final static WeekDay SAT = new WeekDay(); private WeekDay() { } public WeekDay nextDay() { if (this == SUN) { return MON; } else if (this == MON) { return TUE; } else if (this == TUE) { return WED; } else if (this == WED) { return THU; } else if (this == THU) { return FRI; } else if (this == FRI) { return SAT; } else { return SUN; } } public String toString() { if (this == SUN) { return "星期天"; } else if (this == MON) { return "星期一"; } else if (this == TUE) { return "星期二"; } else if (this == WED) { return "星期三"; } else if (this == THU) { return "星期四"; } else if (this == FRI) { return "星期五"; } else { return "星期六"; } } }