1.Java Enum
@定义枚举:
package com.flynewton.test;
public enum AttributeType {
RED(0),
BLUE(1),
BLACK(2);
private int type;
private AttributeType(int type) {
this.type = type;
}
public int getType() {
return type;
}
}
@测试类:
package com.flynewton.test;
public class AttributeTypeTest {
public static void main(String[] args) {
for (AttributeType type : AttributeType.values()) {
System.out.println(type + "---------" + type.getType());
}
}
}
@测试结果:
RED---------0
BLUE---------1
BLACK---------2