private Map<String, Number> collection;
public static void main(String[] args) throws Exception{
Class<?> clazz = TestgetGenericType.class; //取得 Class
Field field = clazz.getDeclaredField("collection"); //取得字段变量
Type type = field.getGenericType(); //取得泛型的类型
ParameterizedType ptype = (ParameterizedType)type; //转成参数化类型
System.out.println(ptype.getActualTypeArguments()[0]); //取出第一个参数的实际类型
System.out.println(ptype.getActualTypeArguments()[1]); //取出第二个参数的实际类型
}
}