Season.java
package com.sxt.utils.enum2; public enum Season { 春,夏,秋,冬; }
TestSeason.java
package com.sxt.utils.enum2; import java.util.Arrays; //枚举可以用于switch中 public class TestSeason { public static void main(String[] args) { //拿到枚举类中的数据 Season[] values = Season.values(); System.out.println(Arrays.toString(values)); Season 春 = Season.春; switch(春){ case 春: System.out.println("春天到了"); break; case 夏: System.out.println("夏天来了"); break; } } }