Originally posted by Jesper de Jong: Wrap them in the corresponding wrapper classes (int -> Integer, char -> Character, etc.) and the reflection API will automatically unwrap them.
-------------------------------------------- Suppose i have
public void set(int i){ }
public void set(Integer i){ }
And if i wrap the primitive int into Integer wrapper, which of the above methods will be considered. Actually the second one. But i want the first method to invoke. Now how do i do it.
Every method is represented by a distinct "java.lang.reflect.Method" object. You get the Method object for the specific method you want to call, and you invoke it. In other words, you yourself choose between the methods.
If you had worked through the tutorial linked above, you would know this already!