Possible Duplicate:
Overloaded method selection based on the parameter’s real type
How is an overloaded method choosen when a parameter is the literal null value?
When I execute the code below, I get the following output:
Method with String argument Called ..."
Why?
public class StringObjectPOC {
public static void test(Object o) {
System.out.println("Method with Object argument Called ...");
}
public static void test(String str){
System.out.println("Method with String argument Called ...");
}
public static void main(String[] args) {
StringObjectPOC.test(null);
}
}