I am trying to understand how overloading in JAVA works and trying to understand the different overload rules that apply in the case of extension, auto-blocking and varargs in JAVA. I can not understand what is happening in the following scenario:
package package1; public class JustAClass { public static void add(int a, long b) { System.out.println("all primitives"); }
At this point, I get a compilation error on the third call to the add method saying The method is ambiguous for the type Error . Why is this so? What are the rules for determining which method call will work? What exactly happens in the following case? I feel that the fourth overloaded add method should work. Please help me understand the concept of this.
source share