java171-枚举类

定义一个枚举类

//枚举类型
public enum test122 {
    RED,
    GREEN,
    BLUE;
 
 
}
测试类

public class test123 {
    public static void main(String[] args){
        System.out.println( test122.BLUE );
        test122[] sigs=test122.values();
        for(test122 e:sigs){
            System.out.println( "枚举名称" +e.name());
            System.out.println( "枚举的索引" +e.ordinal());
        }
    }
}
 

posted @ 2022-07-05 18:43  前端导师歌谣  阅读(25)  评论(0)    收藏  举报