//获取类型参数
TypeVariable variable = animal.getClass().getTypeParameters()[0];
//获取类型参数的限制,如Animal<T extends Comparable & Serializable>结果为:Comparable 和Serializable;
Type types [] = variable.getBounds();
for(Type type : types){
System.out.println(type);
}
//获取类型参数的名称,如Animal<T>的名称为T
System.out.println(variable.getName());
TypeVariable variable = animal.getClass().getTypeParameters()[0];
//获取类型参数的限制,如Animal<T extends Comparable & Serializable>结果为:Comparable 和Serializable;
Type types [] = variable.getBounds();
for(Type type : types){
System.out.println(type);
}
//获取类型参数的名称,如Animal<T>的名称为T
System.out.println(variable.getName());