I have the two following overloaded methods:
public static void test(Integer n) {
System.out.println("Integer");
}
public static void test(Number n) {
System.out.println("Number");
}
when I invoke the test method with null
, something like that:
public static void main(String[] args) throws Exception {
test(null);
}
I receive:
Integer
Could you please explain why do I receive the Integer
and not a compilation error because it is really not obvious with null
parameter what test
method should be executed?