标签:rgba key any sorry 通过 com static out value
package com.company.suanfa;
/**
* 枚举写法和使用测试
* */
public enum Color {
FIRST("01", "一月"), SECOND("02", "二月");
// 通过key获取value
/**
* String key="01";
* System.out.println("key:"+key+",value="+Color.getValue(key));
*
* */
public static String getValue(String key) {
for (Color c : Color.values()) {
if (c.getKey() == key || c.getKey().equals(key)) {
return c.value;
}
}
return "sorry,未匹配到";
}
Color(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
private String value;
private String key;
}
标签:rgba key any sorry 通过 com static out value
原文地址:https://www.cnblogs.com/ziling2526/p/14765939.html