在java中使用genric获取定义genric类型变量的错误
使用genric类型定义变量
泛型,普通,主类的示例
//Generic Class
public class A <T> {
T t;
//getter setter
}
//Normal class
public class B {
//Some variables
}
//Main Class
public class C {
public static void main(String[] args) {
//Fine with normal class
doSomeOpration(B.class);
//Call doSomeOpration with genric class
doSomeOpration(A<B>.class); //getting error not resolved A<B> generic type
}
public <T> static void doSomeOpration(Class<T> clazz) {
//Do Some opration with clazz
}
}
答案 0 :(得分:0)