泛型获取类型参数方法
//获取类型参数
TypeVariable variable = animal.getClass().getTypeParameters()[0];
//获取类型参数的限制,如Animal
Type types [] = variable.getBounds();
for(Type type : types){
System.out.println(type);
\}
//获取类型参数的名称,如Animal
System.out.println(variable.getName());
还没有评论,来说两句吧...