public class ReflectDemo2 {
Map<String,Integer> map = new HashMap<String, Integer>();
List<String> list = new ArrayList<String>();
/**
* @param args
* @throws NoSuchFieldException
* @throws SecurityException
*/
public static void main(String[] args) throws SecurityException, NoSuchFieldException {
// TODO Auto-generated method stub
Class clazz = ReflectDemo2.class;
Field f = clazz.getDeclaredField("list");
Class a = f.getType();
System.out.println(a.getName());
Type t = f.getGenericType();
ParameterizedType pt = (ParameterizedType)t;
Type[] ptas = pt.getActualTypeArguments();
for(Type pta : ptas){
System.out.println(pta);
}
}
}java.util.Listjava.lang.Class
1867

被折叠的 条评论
为什么被折叠?



