Why does `System.out.println(null);` give “The method println(char[]) is ambiguous for the type PrintStream error”?
问题 I am using the code: System.out.println(null); It is showing the error: The method println(char[]) is ambiguous for the type PrintStream Why doesn't null represent Object ? 回答1: There are 3 println methods in PrintStream that accept a reference type - println(char x[]) , println(String x) , println(Object x) . When you pass null , all 3 are applicable. The method overloading rules prefer the method with the most specific argument types, so println(Object x) is not chosen. Then the compiler