Ambiguity between 'identifier' and 'identifier'
The compiler could not distinguish the correct method to execute. This error usually occurs when two overloaded methods have related argument lists and the method call cannot be differentiated between the two methods. Ensure your method call is not using a parameter that conflicts with another overloaded method. Another way to avoid this error is to change the argument lists of the two overloaded methods so that they have a different number of arguments or more uniquely defined parameter data types.
The following example illustrates this error:
public class Simple {
static void method1(Simple2 s2, Simple3 s3) {
// do something meaningful
}
static void method1(Simple3 s3, Simple2 s2) {
// do something meaningful
}
public static void main(String args[]) {
Simple2 s2 = new Simple2();
method1(s2, s2);
// error: Ambiguity between Simple2 and Simple3
}
}
class Simple2 extends Simple3 {
// do something meaningful
}
class Simple3 {
// do something meaningful
}