Why sifter(C[]... c2) is called while calling only sifter() with no argument. I think here should be ambiguity in methods but the code is compiling and giving the output as -41.
package abc;
class A {}
class B extends A {}
class C extends B {}
public class ComingThru {
static String s = "-";
public static void main(String...a) {
A[] aa = new A[2];
B[] ba = new B[2];
sifter();
sifter(aa,ba);
System.out.println(s);
}
static void sifter(A[]... a2) {
s += "1";
}
static void sifter(C[]... c2) {
s += "4";
}
static void sifter(B[]... b1) {
s += "2";
}
}
14: invokestatic #29 // Method sifter:([[LC;)Vthis is the byte code for line sifter(); and from there we can figure out it is converting methodsifter()tosifter(C[]... c2)