eum枚举

Posted 老邱2

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eum枚举相关的知识,希望对你有一定的参考价值。

1.枚举案例

package com.eum;

public enum Type {

    //列出枚举
    insert(1),update(2),select(3),delete(4);
    
//    设置属性值
    private Integer value;

    private Type(Integer value) {
        this.value = value;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }
    
    public static void main(String[] args) {
        //获取枚举列表
        Type [] t=Type.values();
        for (Type type : t) {
            System.out.println(type);
        }
        //获取具体值
        System.out.println(Type.delete.getValue());
    }
}

 

以上是关于eum枚举的主要内容,如果未能解决你的问题,请参考以下文章