arjun srivastava wrote:
why it should be the compiler error?
perhaps you are thinking static method can't be override but here method is overloaded.
remember varag is a loser in each and every case
I understand the confusion, because the call to printName(
String, String) is ambiguous in this case. However, the post mentioned by Wouter Oet clearly states the compiler resolving this ambiguity by choosing the declared two-argument method over the varargs variant. In this case it is resolved by precedence of a fixed-number-of-arguments method over a method with varargs.