Given the code below:
it compiles and runs with the output:
This is the superclass2
so the method aMethod(int) in picked in class Pointx being more specific
HOWEVER: IN JLS 2.0/126.96.36.199 - OVERLOADING - specific methods
" Let m be a name and suppose that there are two declarations of methods named m, each having n parameters. Suppose that one declaration appears within a class or interface T and that the types of the parameters are T1, . . . , Tn; suppose moreover that the other declaration appears within a class or interface U and that the types of the parameters are U1, . . . , Un. Then the method m declared in T is more specific than the method m declared in U if and only if both of the following are true:
* T can be converted to U by method invocation conversion.
* Tj can be converted to Uj by method invocation conversion, for all j from 1 to n. "
according to these definition the first (*) is not true in our case, since the T is a superclass.
In an earlier post dated march 16 2000 from where I took the example, for this code they get compile error, because of the rules above
I use the latest compiler fron Sun, so which one is right ???
Edited by Corey McGlone: Added CODE Tags and formatted code for readability.
[ April 29, 2004: Message edited by: Corey McGlone ]
[ May 01, 2004: Message edited by: Barry Gaunt ]