Constructor getTypeParameters() method in Java with Examples Last Updated : 18 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 the Method Object generic declaration contains no type variables. Syntax: public TypeVariable<Constructor<T>>[] getTypeParameters() Parameters: This method does not accept any parameters. Return value: This method returns an array of TypeVariable objects that represent the type variables declared by this generic declaration. Exception: This method throws GenericSignatureFormatError if the generic signature of this generic declaration does not conform to the format specified in The Java™ Virtual Machine Specification. Below programs illustrate the getTypeParameters() method: Program 1: Java // Java program to demonstrate // Constructor.getTypeParameters() method import java.lang.reflect.Constructor; import java.lang.reflect.TypeVariable; public class GFG { public static void main(String... args) throws NoSuchMethodException { // Create Test class Class<Test> cls = Test.class; // Create Constructor Object Constructor[] constructors = cls.getConstructors(); // get Type Parameters TypeVariable[] typeVariables = constructors[0].getTypeParameters(); System.out.println("TypeVariables:" + typeVariables); } } class Test<N extends Number> { public Test(N n) {} } Output: TypeVariables:[Ljava.lang.reflect.TypeVariable;@15db9742 Program 2: Java // Java program to demonstrate // Constructor.getTypeParameters() method import java.lang.reflect.TypeVariable; public class GFG { public static void main(String... args) { // get Type Parameters TypeVariable<Class<GFG_Demo> >[] typeParameters = GFG_Demo.class.getTypeParameters(); // print result for (TypeVariable<Class<GFG_Demo> > typeParameter : typeParameters) { System.out.println(typeParameter); } } private static class GFG_Demo<N, E> { } } Output: N E References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#getTypeParameters() Comment More infoAdvertise with us Next Article Constructor getTypeParameters() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Constructors Java-Functions java-lang-reflect-package Practice Tags : Java Similar Reads Constructor getParameterCount() method in Java with Examples The getParameterCount() method of java.lang.reflect.Constructor class is used to return the number of parameters present on this constructor object. Every constructor contains a number of parameters starting from zero to many. This method is helpful to get those numbers of parameters. Syntax: public 2 min read Class getTypeParameters() method in Java with Examples 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>> ge 2 min read Constructor getGenericParameterTypes() method in Java with Examples The getGenericParameterTypes() method of java.lang.reflect.Constructor class is used to return an array of objects that represent the types of the parameters present on this constructor object. The arrangement Order of the returned array from this method is the same as the order of parameter present 2 min read Constructor getParameterAnnotations() method in Java with Examples The getParameterAnnotations() method of a Constructor class is used to get a two-dimensional Annotation array that represent the annotations on the formal parameters of this Constructor. If the Constructor contains no parameters, an empty array will be returned. If the Constructor contains one or mo 2 min read Constructor getName() method in Java with Examples The constructor class provides information about a single constructor for a class and it also provides access to that constructor. The getName() method of java.lang.reflect.Constructor is used to return this constructor name, as a string. Constructor name is the binary name of the constructor's decl 1 min read Like