首先,枚举方法不应大写。它们是与其他方法一样的方法,具有相同的命名约定。
其次,您所做的并不是建立枚举的最佳方法。不要为每个值使用值的数组,而应为每个值使用单独的变量。然后,您可以像其他任何类一样实现构造函数。
以下是所有上述建议的处理方式:
public enum States { ... MASSACHUSETTS("Massachusetts", "MA", true), MICHIGAN ("Michigan", "MI", false), ...; // all 50 of those private final String full; private final String abbr; private final boolean originalcolony; private States(String full, String abbr, boolean originalcolony) { this.full = full; this.abbr = abbr; this.originalcolony = originalcolony; } public String getFullName() { return full; } public String getAbbreviatedName() { return abbr; } public boolean isOriginalcolony(){ return originalcolony; }}


