package chapter02;
public enum Season {
//定义四个变量 SPRING,SUMMER,AUTUMN,WINTER; //定义一个私有构造方法 private Season(){ }}-----------------------
package com.bjpowernode.t02;
public class Test01 {
public static void main(String[] args) {
Season spring = Season.SPRING; System.out.println(spring.name()); //返回枚举中常量的顺序,从0开始计数 System.out.println(spring.ordinal()); Season[] values = Season.values();//编译之后生成的方法 for(Season sea:values) { System.out.println(sea); } }}