package object01;
public enum Season { //定义枚举类
spring, summer, autumn, winter;}//测试
public class EnumTest {
public void judge(Season a) { switch (a) { case spring: System.out.println("春暖花开"); break; case summer: System.out.println("夏日炎炎"); break; case autumn: System.out.println("秋高气爽"); break; case winter: System.out.println("冬雪皑皑"); break; } }public static void main(String[] args) {
for (Season s : Season.values()) {// 遍历枚举类元素.values()方法 System.out.println(s); } new EnumTest().judge(Season.spring); //春暖花开 }