Why ambiguous error when using varargs overloading with primitive type and wrapper class? [duplicate]
This question already has an answer here: Ambiguous varargs methods 4 answers I do not understand why here in case 1, it is not giving compilation error, contrary in case 2 (varargs), it gives compilation error. Can anyone please elaborate what differences the compiler makes in these two cases? I went through many posts about it, but not able to understand it yet. Case #1 public class Test { public void display(int a) { System.out.println("1"); } public void display(Integer a) { System.out.println("2"); } public static void main(String[] args) { new Test().display(0); } } The Output is: 1 Case