[quote]It’s a shame that polymorphism doesn’t automatically do this for us… that is, if the object is of type Grape, then it could automatically call .eat(Grape g) instead of .eat(Fruit f). Just pick the most specific type and work your way up until you find a matching function.
[/quote]
Yes, I’ve been complaining about this for years - java is not (was not) truly polymorphic under the non-language-specific definitions I was given as an undergrad, and it’s a huge problem for library developers. But as I understand it the co-variant types of java 5 fix this “oversight”.
The ONLY reason I’ve ever heard for java not doing this originally was that performance would suffer considerably - each function lookup would have a lot of extra overhead (at least one more indirection, more in cases where otherwise it could have been optimized, and potentially many lookups if there are many “possible” matching functions).