Great thanks,<br />Luco Zhao
- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Originally posted by Corey McGlone:
Notice, however, that the fact that the method invocation is ambiguous is dependent upon the fact that the test method is overridden in class Sub. Try commenting out that overriding method and see what happens.
Corey
Great thanks,<br />Luco Zhao
Originally posted by Jessica Sant:
because the value of the character 'm' is 109 -- and that value can be interpretted as char or as a float. So the compiler doesn't know which version of the method test it should run.
"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
If the form is Primary . Identifier, then the name of the method is the Identifier and the class or interface to be searched is the type of the Primary expression.
The class or interface determined by the process described in �15.12.1 is searched for all method declarations applicable to this method invocation; method definitions inherited from superclasses and superinterfaces are included in this search.
because the value of the character 'm' is 109 -- and that value can be interpretted as char or as a float. So the compiler doesn't know which version of the method test it should run.
But this is the case also with
b.test(1);
1 is char/int and can be widend to float also.
The precise definition is as follows. 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.
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
None of them are most specific than the other. Because considering the types of the parameters, char is widdening convertible to float, BUT super is not to Sub.
SCJP2. Please Indent your code using UBB Code