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 on this constructor object. If the constructor has no parameters then the method returns an array of length 0.
public Type getGenericParameterTypes()
Parameters: This method accepts nothing.
Return: This method returns an array of Types that represent the formal parameter types of the underlying executable, in declaration order.
Exception: This method throws following exceptions:
- GenericSignatureFormatError: if the generic method signature does not conform to the format specified in The Java™ Virtual Machine Specification.
- TypeNotPresentException: if the underlying executable’s throws clause refers to a non-existent type declaration.
- MalformedParameterizedTypeException: if the underlying executable’s throws clause refers to a parameterized type that cannot be instantiated for any reason.
Below programs illustrate getGenericParameterTypes() method:
Parameters : class GFG int long double
No of Parameters: 3
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.