Java Class.getTypeParameters()
Syntax
Class.getTypeParameters() has the following syntax.
public TypeVariable <Class <T>>[] getTypeParameters()
Example
In the following code shows how to use Class.getTypeParameters() method.
/*from ww w .ja v a2 s . c om*/
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.