转载和积累系列 - JAVA枚举类型常用
2014-05-04 19:15
323 查看
/*最普通的枚举*/ public enum ColorSelect { red, green, yellow, blue; } //带构造函数和属性的枚举类型 public enum TestEnum { TEST_0("init", "100"), TEST_2("php", "200"); private String key; private String value; TestEnum(String key, String value) { this.key = key; this.value = value; } //可以通过key获取value的值 private final static Map<String, String> pool = new HashMap<String, String>(); static { for (TestEnum each : TestEnum.values()) { pool.put(each.key, each.value); } } public static String getValue(String key) { return pool.get(key); } }
相关文章推荐
- 转载和积累系列 - 常用GIT命令
- 转载和积累系列 - Linux常用信息显示命令
- 转载和积累系列 - Linux常用网络命令
- 转载和积累系列 - Linux常用操作命令
- 转载和积累系列 - 分析服务器日志常用命令
- 转载和积累系列 - 常用linux命令大全
- 转载和积累系列 - Linux tar命令常用方法
- 转载和积累系列 - 技巧:java删除jdk后无法重装情况解决
- 转载和积累系列 - 常用正则表达式
- 转载和积累系列 - Linux常用命令记录
- 转载和积累系列 - Linux 常用工作管理命令
- 转载和积累系列 - Lua常用
- 转载和积累系列 - java基本环境安装
- 转载和积累系列 - Java生成doc文档
- 转载和积累系列 - java的反射
- 转载和积累系列 - OpenWrt常用命令
- 转载和积累系列 - java中Keytool的使用总结
- 转载和积累系列 - eclispce 常用快捷键
- 转载和积累系列 - CentOS 常用小技巧集合
- 转载和积累系列 - M3U8文件