84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
java,我想使用枚举实现int到string的转换,能做到吗?就如同字典一样。
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
public enum MyDict { ChineseEnglish(0, "汉语词典"), EnglishChinese(1,"英汉词典"), EnglishEnglish(2,"英英词典"); Integer id; String desc; MyDict(Integer id, String desc) { this.id = id; this.desc = desc; } static MyDict findById(Integer id) { MyDict dict; switch(id) { case 0: dict = MyDict.ChineseEnglish; break; case 1: dict = MyDict.EnglishChinese; break; case 2: dict = MyDict.EnglishEnglish; break; default: throw new IllegalArgumentException("非法ID"); } return dict; } String getDesc() { return desc; } public static void main(String[] args) { String desc = MyDict.findById(0).getDesc(); System.out.println(desc); } }
不知道是不是这个意思
不知道是不是这个意思