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;
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/littlepage/p/10317736.html