为什么此枚举不编译?
public enum Ackr implements Cloneable{
INSTANCE;
public <Ackr extends Cloneable> Ackr getInstance(){
return INSTANCE; //Type mismatch: cannot convert from Ackr to Ackr
// return (Ackr)INSTANCE; //Type safety: Unchecked cast from Ackr to Ackr
}
}
最佳答案
据我所知,该类型参数不是必需的。简单尝试
public Ackr getInstance(){
return INSTANCE;
}