Using superclass type for subclass instance
问题 I know this question has been asked a lot, but the usual answers are far from satisfying in my view. given the following class hierarchy: class SuperClass{} class SubClass extends SuperClass{} why does people use this pattern to instantiate SubClass: SuperClass instance = new SubClass(); instead of this one: SubClass instance = new SubClass(); Now, the usual answer I see is that this is in order to send instance as an argument to a method that requires an instance of SuperClass like here: