We cannot get the date type from the vector<date> vector = new vector<date> () but we can get the type of date in the following way
1. Write a method that side of the following fit Word
public class Itcastannotation {
public static void Main (String args[]) {
2. Get the byte code of this class
Class clazz = Itcastannotation.class;
3. Obtain the method object corresponding to the GetType methods for obtaining the class by reflection
Method method = Clazz.getdeclaredmethod ("GetType", Vector.class);
4 by looking up a jdk1.5 document, you can send a method of getgenericparametertypes () to obtain the parameters of an enumerated type, and return an array
type[] Type = Method.getgenericparametertypes ();
Force the downward type to be converted into his subclass
Parameterizedtype Typep = (parameterizedtype) type[0];
5jdk.1.5 the Getrawtyep () method to obtain the source type
System.out.println (Typep.getrawtype ());
6getActualTypeArguments () Gets an array of type parameters, and the first print gets the type of date
System.out.println (typep.getactualtypearguments () [0]);
}
private static void GetType (Vector<date> Vector) {
}
}