枚举类型的使用 发表于 2019-04-29 更新于 2019-05-03 枚举枚举是final,意味着它不能被继承,他的作用是用来限制输入的类型 12345678910111213141516171819202122232425public enum MaterialType{ UNDEFINED("Undefined", 0,"object"), /** 枚举值码 */ private final String commandType; /** 枚举描述 */ private final String desc; /** * 实现类 */ private final String clazz ; public static MaterialType find(int index) { for (MaterialType c : MaterialType.values()) { if (c.getIndex() == index) { return c; } } return null; }}