------- <a href="http://www.itheima.com" target="blank">android培训</a>
代码演示:
public class GenericTest {
public static void main(String[] args) throws Exception{
//通过反射获取的函数的方法
Method method = GenericTest.class.getMethod("applyVector", Vector.class);
//得到所以参数的泛型类型
Type[] types = method.getGenericParameterTypes();
ParameterizedType pt = (ParameterizedType)types[0];
System.out.println(pt.getActualTypeArguments()[0]);
}
public static void applyVector(Vector<Date> v1){
}
}
<a href="http://www.itheima.com" target="blank">java培训</a>、期待与您交流! ----------