需求

java 中 枚举中使用字符串

解决

public class HelloWorld {
    public static void main(String []args) {
       System.out.println("Hello World!");
	      System.out.println(Season.SPRING.toString());
	      System.out.println(Season.SPRING.value());
    }
}

enum Season {
      SPRING("spring"), SUMMER("summer"), AUTUMN("autumn"), WINTER("winter");

      public final String value;
      private Season(String value) {
	      this.value = value;
      }

      public String value() {
	      return this.value;
      }
}

参考