Class getTypeParameters() method in Java with Examples Last Updated : 27 Jan, 2022 Comments Improve Suggest changes Like Article Like Report The getTypeParameters() method of java.lang.Class class is used to get the type parameters of this entity. This entity can be a class, an array, an interface, etc. The method returns an array of TypeVariable objects representing the type variables.Syntax: public TypeVariable<Class<T>> getTypeParameters() Parameter: This method does not accept any parameter.Return Value: This method returns an array of TypeVariable objects representing the type variables.Below programs demonstrate the getTypeParameters() method.Example 1: Java // Java program to demonstrate getTypeParameters() method import java.util.*; public class Test { public static void main(String[] args) throws ClassNotFoundException { // returns the Class object for this class Class myClass = Class.forName("Test"); System.out.println("Class represented by myClass: " + myClass.toString()); // Get the type parameters of myClass // using getTypeParameters() method System.out.println( "TypeParameters of myClass: " + Arrays.toString( myClass.getTypeParameters())); } } Output: Class represented by myClass: class Test TypeParameters of myClass: [] Example 2: Java // Java program to demonstrate getTypeParameters() method import java.util.*; public class Test { public static void main(String[] args) throws ClassNotFoundException { // returns the Class object for this class Class myClass = Class.forName("java.lang.Integer"); System.out.println("Class represented by myClass: " + myClass.toString()); // Get the type parameters of myClass // using getTypeParameters() method System.out.println( "TypeParameters of myClass: " + Arrays.toString( myClass.getTypeParameters())); } } Output: Class represented by myClass: class java.lang.Integer TypeParameters of myClass: [] Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#getTypeParameters-- Comment More infoAdvertise with us Next Article Class getTypeParameters() method in Java with Examples S srinam Follow Improve Article Tags : Java Java-lang package Java-Functions Java.lang.Class Practice Tags : Java Similar Reads Class getTypeName() method in Java with Examples The getTypeName() method of java.lang.Class class is used to get the type name of this class, which provides the information about this class' type. The method returns the type name of this class in the form of String. Syntax: public String getTypeName() Parameter: This method does not accept any pa 2 min read Constructor getTypeParameters() method in Java with Examples The getTypeParameters() method of a Constructor class is used to get an array of TypeVariable objects declared by this Constructor Object, in declaration order. Elements of array represent the type variables objects declared by Method. An array of length 0 is returned by this getTypeParameters(), if 2 min read Class getInterfaces() method in Java with Examples The getInterfaces() method of java.lang.Class class is used to get the interfaces directly implemented by this entity. This entity can be a class or an interface. The method returns an array of interfaces directly implemented by this entity.Syntax: public Class<T>[] getInterfaces() Parameter: 2 min read Class getName() method in Java with Examples The getName() method of java.lang.Class class is used to get the name of this entity. This entity can be a class, an array, an interface, etc. The method returns the name of the entity as a String.Syntax: public String getName() Parameter: This method does not accept any parameter.Return Value: This 1 min read Class getSuperclass() method in Java with Examples The getSuperclass() method of java.lang.Class class is used to get the super class of this entity. This entity can be a class, an array, an interface, etc. The method returns the super class of this entity.Syntax: public Class<T> getSuperclass() Parameter: This method does not accept any param 2 min read Like