problem description
I use enum to represent an enumerated class
in addition, I use XXX extends Enum to represent an enumerated class
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 decompiled and found to inherit Enum, so the two enumerated classes should be the same.
then I wrote this method (the method receives a Class): inherited from Enum
public static <T extends Enum> T test(Class<T> clazz){
// xxxxxxxxxxxxx
return null;
}
then test it with these two classes
found an error? Why is that? Obviously both classes inherit Enum. It should all be compiled and passed. Ask for advice.
is a little confused, which boss can explain it?