My question: 1)How is that in the first case the method m(GFC206,GFC206) more specific than the other methods? 2)Why is that in the second case m(GFC212,GFC212) not more specfic than any other methods? Please explain
In this sense, "more specific" basically means further removed from the base class, Object. So with each level of inheritance, we can say that a type is getting "more specific."
In the first example, GFC207 extends GFC206, which extends GFC205, which extends Object. Therefore, GFC207 is more specific than GFC206, which is more specific than GFC205, which is more specific than Object.
We're calling a method passing GFC207 references. Because of inheritance, a GFC207 is also a GFC206, and a GFC205, and an Object. So depending on the context, any of these methods could work. But because we have a choice, we want to select the best fit -- that is, the method that takes arguments closest to the GFC207's we have.
In this sense, m(GFC205, GFC206) is more specific than m(GFC205, GFC205) because it treats one of the parameters as a GFC206, which is more specific than a GFC205. But ultimately, m(GFC206, GFC206) is invoked because this is the most specific argument list that fits the parameters we're passing.
The second example is similar, except that it is not clear which method provides the best fit. On one hand, m(GFC211, GFC213) has an exact fit for one of the parameters, but the other argument type is GFC211, which isn't very specific to what we're passing because GFC213 is a subclass of a subclass of GFC211. On the other hand, m(GFC212, GFC212) might be a better choice because each argument type is an immediate superclass to the GFC213 references we're passing. Which would be better? Based on our argument types, we can't know, and so we can't say that any of these methods is "more specific."
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
How is that in the first case the method m(GFC206,GFC206) more specific than the other methods?
GFC205 can accept any value that GFC206 can accept, but GFC206 cannot accept all values that GFC205 can accept. For example, a parameter of type GFC206 cannot accept arguments of type GFC205. This makes GFC206 more specic than GFC205.
2)Why is that in the second case m(GFC212,GFC212) not more specfic than any other methods?
Because m(GFC211, GFC213) is more specific than m(GFC212,GFC212) in the second parameter but less specific in the first parameter.
[ December 17, 2004: Message edited by: Mike Gershman ] [ December 17, 2004: Message edited by: Mike Gershman ]