I am just learning Java. Not a practicing programmer. The book I am following says, that when overriding a method, the argument types must be the same, but the return types can be polymorphically compatible. My question is why cant the arguments passed to the overriding method not be a subclass type of the supertype expected. In the overloaded method, whatever method I call on the object is guaranteed to be defined on the object.
Aucun commentaire:
Enregistrer un commentaire