Java SE 枚举的基本用法

出于对自己基础的稳打,期末考试后依旧对SE部分进行复习

枚举的基本用法

public enum Season {
SPRING,SUMMER,AUTUMN,WINTER
}
public class Test {
    public static void main(String[] args) {
        Season a=Season.SPRING;
        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;
        }
    }
}

 

posted @ 2019-01-25 01:30  SteveYu  阅读(177)  评论(0编辑  收藏  举报