Given the following example:
=============== =============== ==============
class A {
int method (B a) {
return 1;
}
}
class B extends A {
int method (A b) {
return 2;
}
}
class Test {
public static void main(String[] args) {
System.out.prin tln(new B().method(new B()));
}
}
=============== =============== ===============
When compiling with 1.4.1_02, the compiler is complaining with:
Test.java:13: reference to method is ambiguous, both method method(B)
in A and method method(A) in B match
System.out.prin tln(new B().method(new B()));
When compiling with 1.4.2, the compiler is happy and the program
returns 1
It seems that something has changed with 1.4.2. Unfortunately I could
not find anything in the changes.
Anybody can explain me what has exactly changed with method selection
Thanks
--
Laurent Thery
=============== =============== ==============
class A {
int method (B a) {
return 1;
}
}
class B extends A {
int method (A b) {
return 2;
}
}
class Test {
public static void main(String[] args) {
System.out.prin tln(new B().method(new B()));
}
}
=============== =============== ===============
When compiling with 1.4.1_02, the compiler is complaining with:
Test.java:13: reference to method is ambiguous, both method method(B)
in A and method method(A) in B match
System.out.prin tln(new B().method(new B()));
When compiling with 1.4.2, the compiler is happy and the program
returns 1
It seems that something has changed with 1.4.2. Unfortunately I could
not find anything in the changes.
Anybody can explain me what has exactly changed with method selection
Thanks
--
Laurent Thery
Comment