Ambiguous varargs methods
问题 Here's a code example that doesn't compile: public class Test { public static void main(String[] args) { method(1); } public static void method(int... x) { System.out.println("varargs"); } public static void method(Integer... x) { System.out.println("single"); } } Can someone tell me the reason why these methods are ambiguous ? Thank you in advance. 回答1: Consider the method signatures public static void foo(int a) and public static void foo(Integer a) Before boxing and unboxing, the call foo