I using the following code to get the method input parameter but I getting the wrong params
for example I for set salary I want to get the type (double )and the name (salary) .
what i miss here ?
public void setSalery(double salery) {
this.salery = salery;
}
this is the code
for (Method method : classHandle.getMethods()) {
Class<?>[] parameterTypes = method.getParameterTypes();
for (Class<?> class1 : parameterTypes) {
Field[] declaredFields = class1.getDeclaredFields();
for (Field field : declaredFields) {
System.out.println(field.getName());
}
You can retrieve the parameter types but not the parameter names. They are of no significance except within the method, which at this point is opaque to you.
getDeclaredFields()returns the fields in the types, not the parameter names.To invoke such a method (using your example), assume
Then do