获取泛型类型

来源:互联网 发布:php 会员系统 编辑:程序博客网 时间:2024/05/22 14:23

  {
 
            Method applyMethod = GenericTest.class.getMethod("applyVector", Vector.class);
             Type[] types = applyMethod.getGenericParameterTypes();
             ParameterizedType pType = (ParameterizedType)types[0];
             System.out.println(pType.getRawType());
             System.out.println(pType.getActualTypeArguments()[0]);
  }
 
  public static void applyVector(Vector<Date> v1){
   
  }

0 0
原创粉丝点击