Java 枚举
Posted 超轶绝尘
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java 枚举相关的知识,希望对你有一定的参考价值。
import java.util.HashMap; import java.util.Map; public enum CheckStatus { NO_SUBMIT(0,"未提审"), CHECKING(1, "审批中"), REFUSED(2,"已驳回"), THROUGH(3,"已通过"); public static Map<Integer,String> statusMap=new HashMap(){{ put(NO_SUBMIT.getKey(), NO_SUBMIT.getValue()); put(CHECKING.getKey(), CHECKING.getValue()); put(REFUSED.getKey(), REFUSED.getValue()); put(THROUGH.getKey(), THROUGH.getValue()); }}; private int key; private String value; CheckStatus(int key,String value){ this.key = key; this.value = value; } public int getKey() { return key; } public void setKey(int key) { this.key = key; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } }
public enum CheckOp { /**启动流程*/ PROCESS_START(0), /**任务办理*/ PROCESS_TASK_FINISH(1), /**任务驳回*/ PROCESS_TASK_ROLLBACK(2); private final int value; CheckOp(int value) { this.value = value; } public int getValue() { return value; } }
以上是关于Java 枚举的主要内容,如果未能解决你的问题,请参考以下文章