Class.getTypeParameters() has the following syntax.
public TypeVariable <Class <T>>[] getTypeParameters()
In the following code shows how to use Class.getTypeParameters() method.
/*from ww w . ja va 2 s . c o m*/ import java.lang.reflect.TypeVariable; import java.util.List; public class Main { public static void main(String[] args) throws Exception { // returns an array of TypeVariable object TypeVariable[] tValue = List.class.getTypeParameters(); System.out.println(tValue[0].getName()); } }
The code above generates the following result.