How would I go about to get the Parameter Type? When I previously attempted to just do classMethods[i].getParameterTypes()
my result ended up being Ljava.lang.Class;@4c5bb434
and it repeated with different values for each method.
classMethods is an array of Method that obtains all the declaredmethods of the class.
Yes, getParameterTypes()
returns an array - one element for each parameter. Just use:
for (Class<?> clazz : classMethods[i].getParameterTypes()) {
System.out.println("Parameter type " + clazz.getName());
}
(Adjust the output according to your need, of course.)
See more on this question at Stackoverflow