提问人:bsobaid 提问时间:11/17/2023 最后编辑:Stephen Cbsobaid 更新时间:11/17/2023 访问量:41
为什么父级的类型不允许使用 .class [已关闭]
why .class is not allowed on the parent's type [closed]
问:
为什么不允许在泛型类型的父类上.class?
public class DataService<TYPE extends ClientData> extends BaseDataService<TYPE>{
public DataService(){
//So existing consumer dont have to pass clientData.class as argument
super(ClientData.class) //compile error.
// why cant I refer to the explicit type here?
}
public DataService(Class<TYPE> cls){
//This is useful if I want to inherit from DataService
super(cls);
}
}
答: 暂无答案
评论