Open In App

Method Class | getGenericParameterTypes() method in Java

The java.lang.reflect.Method.getGenericParameterTypes() method of Method class returns an array of Type objects that represent the parameter types, declared in method at time of coding. It means that the getGenericParameterTypes() method returns array of parameters that belongs to method object. It returns an array of length 0 if the method object takes no parameters.

If a formal parameter type is a parameterized type, the Type object returned for it must accurately reflect the actual type parameters used in the source code. e.g for method public void getValue(T value){} substitute a type parameter T with a parameterized type (i.e., List) then method will return “java.util.List” as parameter type.



Syntax:

public Type[] getGenericParameterTypes()

Return Value: This method returns an array of Types that represent the formal parameter types of the method object, in declaration order.



Exception: This method throws following exceptions:

Article Tags :