问题描述
我用enum来表示一个枚举类
另外,再用 XXX extends Enum来表示一个枚举类
public final class ApprovalStatusEnum extends Enum {
private static final long serialVersionUID = -502007467073163619L;
private String label;
public static final ApprovalStatusEnum PASS = new ApprovalStatusEnum("PASS", "通过");
public static final ApprovalStatusEnum REJECT = new ApprovalStatusEnum("REJECT", "退回");
public static final ApprovalStatusEnum WAIT = new ApprovalStatusEnum("WAIT", "待审核");
public ApprovalStatusEnum(String name, String label) {
super(name);
this.label = label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}
public enum ApprovalStatusEnum1 {
PASS("PASS", "通过"),
REJECT("REJECT", "退回"),
WAIT("WAIT", "待审核");
private String name ;
private String label;
ApprovalStatusEnum1(String name, String label) {
this.name = name;
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}
enum反编译之后发现是继承Enum的,那么这两个枚举类应该是一样的呀。。。
之后我写了这个方法(方法接收一个继承于Enum的Class):
public static T test(Class clazz){
// xxxxxxxxxxxxx
return null;
}
然后用这两个类测试了一下
发现有错误???这是为什么呢?明明两个类都继承了Enum呀。那应该都会编译通过的呀。求高人指点一下。
有点懵,哪位大佬可以解释下?