Method overload selection with null
问题 Given this code: class Overloading extends Object { static public void target(Object val, String chk) { System.out.println("Object["+val+"] :: Should be "+chk); } static public void target(String val, String chk) { System.out.println("String["+val+"] :: Should be "+chk); } static public void main(String[] args) { Object obj=null; target(null ,"Object"); target((Object)null,"Object"); target(obj ,"Object"); } } the output is (unexpectedly) as follows: String[null] :: Should be Object Object