public class CompilerConfuse {
public static void main(String[] args) {
A a =new A();
a.method(null); // error line
}
}
class A
{
public void method(Integer a)
{
System.out.println("In Integer argument method" + a);
}
public void method(Object a)
{
System.out.println("In Object argument method" + a);
}
public void method(String a)
{
System.out.println("In String argument method " + a);
}
}
In Integer and String overload method,Compiler could not able to decide which one to call.Why this happening?
If we remove either of String or Integer overload method it is not giving error when passing null.