Hi Nikunj,
As Abhijit pointed out, the code won't compile as it currently stands without explicitly casting 7 to a short. But even if you did, the method invocation will be bound to the non-varargs version rather than the varargs version.
I'd summarized how the compiler tries to resolve these ambiguous calls in
another recent thread. For convenience, I'll reproduce the key part here:
There's a well-defined rule for resolving these ambiguities. Basically, the compiler will go through three phases to match a method invocation to a method signature:
Phase 1: Match without boxing/unboxing and without var-args
Phase 2: Match with boxing/unboxing and without var-args
Phase 3: Match with boxing/unboxing and with var-args
If the compiler finds a match at an earlier phase, it will not proceed to subsequent phases. The basic rationale behind this rule is that this will preserve backward compatibility with older versions of Java. All method invocations from Java 1.4 and before will continue to be bound in the same way in Java 1.5.
[ November 17, 2007: Message edited by: Kelvin Lim ]