1. public class Main {
    2. public static void main(String[] args) {
    3. Weekday day = Weekday.SUN;
    4. if (day.dayValue == 6 || day.dayValue == 0) {
    5. System.out.println("Work at home!");
    6. } else {
    7. System.out.println("Work at office!");
    8. }
    9. }
    10. }
    11. enum Weekday {
    12. MON(1), TUE(2), WED(3), THU(4), FRI(5), SAT(6), SUN(0);
    13. public final int dayValue;
    14. private Weekday(int dayValue) {
    15. this.dayValue = dayValue;
    16. }
    17. }
    1. public class Main {
    2. public static void main(String[] args) {
    3. Weekday day = Weekday.SUN;
    4. System.out.println(day.dayValue);
    5. System.out.println(day.chinese);
    6. if (day.dayValue == 6 || day.dayValue == 0) {
    7. System.out.println("Today is " + day + ". Work at home!");
    8. } else {
    9. System.out.println("Today is " + day + ". Work at office!");
    10. }
    11. }
    12. }
    13. enum Weekday {
    14. MON(1, "星期一"), TUE(2, "星期二"), WED(3, "星期三"), THU(4, "星期四"), FRI(5, "星期五"), SAT(6, "星期六"), SUN(0, "星期日");
    15. public final int dayValue;
    16. private final String chinese;
    17. private Weekday(int dayValue, String chinese) {
    18. this.dayValue = dayValue;
    19. this.chinese = chinese;
    20. }
    21. @Override
    22. public String toString() {
    23. return this.chinese;
    24. }
    25. }