System.out.println(ErrorCodeEnum.SYSTEM_ERROR.name()); System.out.println(ErrorCodeEnum.valueOf(ErrorCodeEnum.class, "ILLEGAL_ARGUMENT")); }String name() : Returns the name of this enum constant, exactly as declared in its enum declaration. 返回枚举常量声明时的字符串。int ordinal() : 返回枚举常量的声明时的顺序位置,像数组的索引一样,从0开始。valueOf(Class<T> enumType, String name) : 其实是从 枚举常量的字符串到 枚举常量的转换,相当于一个工厂方法。name() 方法是从 枚举常量 到 字符串的转换,而 valueOf 是字符串到 枚举常量的转换。values() : 该方法是一个隐式的方法,All the constants of an enum type can be obtained by calling the implicit public static T[] values() method of that type. 用于遍历枚举中的所有的枚举常量。4. enum相关的数据结构:EnumMap, EnumSet 具体可以参考jdk文档。5. enum 相对于 常量的优势(略)本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-05/117979.htm