Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何将枚举值转换为 int?
我正在尝试为我的枚举分配值,例如:
enum it { one=5,two=7};
我不敢相信我不记得如何做到这一点。
有人可以帮我吗??
非常感谢你
enum it { one(5), two(7); private int value; it(int value){this.value = value;} public int getValue(){return value;} };
System.out.println(it.one.getValue());
输出:
5