Method overloading using derived types as parameters in Java
问题 Let's say I have existing code which I want to extend but also to avoid changing it as much as possible. Somewhere around this code there is a method that receives some type. Engine.method(Base b) Now, I want to extend this functionality. So I extends Base into a type called Derived which holds some more data I need and I also implements another method that receives the Derived type and do something different with it. Engine.method(Derived d) But I don't want to change the original call to