枚举类型的静态方法,这个不属于API,是JAVA核心的一部分
你用过enum吗
public enum TYPE {
A_TYPE(1),B_TYPE(2);
public int type;
private TYPE(int i) { this.type=i;}
}
其他是模仿了C的枚举,不过他比C的枚举多了些功能,可以看做是个简化的class
获取枚举值的方法一种是直接调用:int i = TYPE.A_TYPE.type; // i为1
另一种就是根据值来反向获取TYPE对象: TYPE type = TYPE.valueOf(1); // type=TYPE.A_TYPE
[Quote=引用 1 楼 的回复:]
枚举类型的静态方法,这个不属于API,是JAVA核心的一部分
你用过enum吗
public enum TYPE {
A_TYPE(1),B_TYPE(2);
public int type;
private TYPE(int i) { this.type=i;}
}