- public enum FruitType {
- //Key==>Value
- Apple("苹果"),
- Pear("梨"),
- Orange("橘子");
- private String message;
- private FruitType(String message) {
- this.message = message;
- }
- //此方法可以获取到Value
- public String toString() {
- return message.toString();
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/280520133621.html
来源: http://www.codesnippet.cn/detail/280520133621.html