Item 31: Use instance fields instead of ordinals
程序员文章站
2022-05-18 14:41:15
...
1. All enums have an ordinal method, which returns the numerical position of each enum constant in its type.
2. Never derive a value associated with an enum from its ordinal; store it in an instance field instead.
3. ordinal is designed for use by general-purpose enum based data structures such as EnumSet and EnumMap. Unless you are writing such a data structure, you are best off avoiding the ordinal method entirely.
上一篇: 一个7,8年的phper学习java之路
下一篇: Linux上安装mysql数据库