枚举类的练习

package com.javaenum;

public enum SessionEnum {
     Spring,summber,autumn,winner
}

 

测试枚举

 

package com.javaenum;

public class TestEnum {
    public static void judge(SessionEnum s){
    	switch (s) {
		case Spring:
			System.out.println("春天来了!");
			break;
		case summber:
			System.out.println("夏天来了!");
			break;
		case autumn:
			System.out.println("秋天来了!");
			break;
		case winner:
			System.out.println("冬天来了!");
			break;
    	}
    }
    
    public static void main(String[] args) {
    	//打印出每一个枚举的值
		for (SessionEnum s:SessionEnum.values()) {
			System.out.println(s);
		}
		//测试枚举
		judge(SessionEnum.Spring);
	}
}

 

 

你可能感兴趣的:(枚举)