标签:string ntc this enum eof 总结 type login valueof
1. 枚举类型总结
public enum OperationEnum { LOGIN; // 登录 }
int ordinal = OperationEnum.valueOf("LOGIN").ordinal(); String name = OperationEnum.valueOf("LOGIN").name(); System.out.println(ordinal); // 0 System.out.println(name); // LOGIN
2. 枚举类型举例2
int ordinal = ATTRIBUTE_TYPE.valueOf("AGREEMENT").ordinal(); // 1
int ordinal2 = ATTRIBUTE_TYPE.AGREEMENT.ordinal(); // 1
System.out.println(ordinal); // 1
System.out.println(ordinal2); // 1
String name = ATTRIBUTE_TYPE.valueOf("AGREEMENT").name(); // AGREEMENT
String name2 = ATTRIBUTE_TYPE.AGREEMENT.name(); // AGREEMENT
System.out.println(name); // AGREEMENT
System.out.println(name2); // AGREEMENT
String getValue = ATTRIBUTE_TYPE.AGREEMENT.getValue(); // readc
String value = ATTRIBUTE_TYPE.AGREEMENT.value; // agreementc
System.out.println(getValue); // readc
System.out.println(value); // agreementc
ATTRIBUTE_TYPE attribute_type = ATTRIBUTE_TYPE.AGREEMENT; //AGREEMENT
System.out.println(attribute_type); // AGREEMENT
public enum ATTRIBUTE_TYPE { READ("readCount"), AGREEMENT("agreementCount");
private final String value; ATTRIBUTE_TYPE(String value) { this.value = value; } public String getValue() { return value; } }
标签:string ntc this enum eof 总结 type login valueof
原文地址:http://www.cnblogs.com/an5211/p/7773764.html