Well after compilation a var-args method is converted into an array
Eg
method(
String... args)
after compilation will become
method(String[] args)
So if your parameter is an array it will become a 2-d array
method(String[]... args)
after compilation will become
method(String[][] args)
So in you case methods
will become
And as you know all arrays are sub-classes of Object[] and Object[] is itself a sub-class of Object.
So the call
sifter(aa); //aa is A[]
will match the method
static void sifter(Object o)
{
s += "4";
}
call to
sifter(ba); //ba is B[]
will match
static void sifter(B[] b1)
{
s += "3";
}
and call to
sifer(7); //it will become sifer(new Integer(7));
will match
static void sifter(Object o) //Integer will be upcasted to Object
{
s += "4";
}
I hope you will get it....