public enum Color{ //定义枚举并赋值 RED("红色", 1), Blue("蓝色", 2), Yellow("黄色", 3); private String colorName; private int colorCode; //public String .... 其他public方法 private Color(colorName, colorCode){ this.colorName = colorName; this.colorCode = colorCode; } public String getColorName(){ return colorName; } public void setColorName(name){ this.colorName = name; } public int getColorCode(){ return colorCode; } public void setColorCode(code){ this.colorCode = code; } }
时间: 2024-11-05 19:40:01