I just found out about a very interesting Java trick:
void method1(Integer... a){
}
So you can give this method as many integers as you want.>
I'm half guessing, but like thinksteep said, Integer...
is actually treated as an Integer
array, which implies that your method call would have to do two coercions to make it match the first method (boxing the int
s to Integers
, and treating your argument list as an array rather than simply two different arguments). Whereas, no coercions are required to make it match the second method.
OK, I can see several others have already quoted the JLS with more specificity than I have provided, while I was typing this out.