See the code below:
// 1st method
private static void method(Object o){
System.out.println(\"object method\");
}
// 2nd method
private static void method
Because Object...
is essentially Object[]
and since null
is a valid Object[]
, it will match to the most specific one.
If you had 3 methods with first having Object
parameter, the second having SubClass
param and the last having SubSubClass
param, the last one would be chosen.
Whereas if you add a method with a String
parameter to your original code, you will get a compile time error, since there is no longer a single most specific match for null
.