The reason goes for the Object overload instead of the Integer var-arg is to allow older code to keep the same functionality even with the introduction of var-args for method calls. This means that using a var-arg argument for a method is the lowest priority. What it does is it boxes the int to and Integer object and promotes it to its Object superclass.
I just ran the same code and the output that I got was 242 instead of 212. This is what the output should be because widening the int to a long, which is done implicitly, has a higher priority to boxing it to and Integer and then widening it to its Object superclass.
Nathan Warner wrote: I just ran the same code and the output that I got was 242 instead of 212. This is what the output should be because widening the int to a long, which is done implicitly, has a higher priority to boxing it to and Integer and then widening it to its Object superclass.
Hi Nathan,
thanks for your reply. I also ran the code and I got 242. I think the book was mistyped.