欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java枚举类型使用的小例子 Java 

程序员文章站 2022-06-05 21:26:30
...
java枚举类型使用的小例子

public interface PositionConstants {

public static enum POSITIONS{

GENERALMANAGER("00000001","总经理"),
SUPERVISOR("00000002","部门主管"),
CLIENTMANAGER("00000003","客户经理"),
ADMIN("00000004","部门ADMIN"),
TECMANAGER("00000005","技术经理"),
TECENGINEER("00000006","技术工程师"),
QA("00000007","QA"),
COORDINATOR("00000008","协调服务员"),
FINANCIAL("00000009","财务人员");

private String v;
private String k;
       
POSITIONS(String key,String value) {
                    k=key;
                     v = value;
        }

public String getV() {
return v;
}

public void setV(String v) {
this.v = v;
}

public String getK() {
return k;
}

public void setK(String k) {
this.k = k;
}
}


调用:PositionConstants.POSITIONS.GENERALMANAGER.getK();
转成数组遍历:
for(int i=0;i<PositionConstants.POSITIONS.values().length;i++){
String positionID=PositionConstants.POSITIONS.values()[i].getK();
String positionName=PositionConstants.POSITIONS.values()[i].getV();
相关标签: Java