- public class GenericTest
- {
- public List<String> list = new LinkedList<String>();
- public static void main(String[] args) throws SecurityException, NoSuchFieldException
- {
- ParameterizedType pt = (ParameterizedType) GenericTest.class.getField(
- "list").getGenericType();
- System.out.println(pt.getActualTypeArguments().length);
- System.out.println(pt.getActualTypeArguments()[0]);
- }
- }
获得List<T> T的类型
最新推荐文章于 2023-07-24 14:34:30 发布