62,628
社区成员
发帖
与我相关
我的任务
分享
public <T> boolean test(Class<T> type) {
try {
T t=type.newInstance();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
下面就不行了,通不过编译
public boolean test(Class type) {
try {
T t=(T)type.newInstance();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}