枚舉轉map
阿新 • • 發佈:2018-11-12
nbsp span sta 支付 class this ati clas public
import java.util.HashMap; import java.util.Map; public enum PayType { ALIPAY("支付寶掃碼", 15), WEIXIN_PAY("微信掃碼", 16) PayType(String name, int value) { this.name = name; this.value = value; } public int value; public String name; public static Map<String, PayType> typeMap = newHashMap<String, PayType>(); static { PayType[] types = PayType.values(); for (PayType type : types) { typeMap.put(String.valueOf(type.value), type); } } }
枚舉轉map