my doubt is how the compiler can select specific method internally?
is it compare first parameter of method1 with first parameter of method2 and second parameter to second parameter and third parameter to third parameter? is it select specific method based on the only first matching parameter(widening>boxing>var-args)?
is it consider most no of matches in a method after comparing the parameters in different methods?
can anyone give me explanation? [ November 02, 2008: Message edited by: Ganeshkumar cheekati ]
in the code that you gave the compiler chooses method2 because it has to do just one widening and no boxing. I think the compiler first matches a method directly, then widens each argument one by one, then boxes each argument one by one, then boxes and widens each argument and so on. I cannot tell you the exact order as there are so many things like var-args etc...
Joined: Oct 13, 2008
i thought that the compiler can select method1 in which only one widening takes place. but it is compilation error as ambiguity in methods.
If you need the complete details, then I think you should read JLS (Java Language Specification). Here's a URL to how method invocations are resolved. I think if you read it completely, then you will get answers to all your questions.....