in JAVA, why i get output from Integer parameter for null ?
package com.company;
class father {
public void sum(Object a) {
System.out.println("Object");
}
public void sum(Integer a) {
System.out.println("Integer");
}
}
public class children extends father {
public static void main(String[] args) {
father f = new children();
f.sum(2);
f.sum(new Object());
f.sum(null);
}
}
I was expecting null will get cast to object and I will get Object as output, but i get Integer as output.
I got output like this.... Integer Object Integer