What is method hiding in Java? Even the JavaDoc explanation is confusing

前端 未结 7 1302
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 02:36

Javadoc says:

the version of the hidden method that gets invoked is the one in the superclass, and the version of the overridden method that gets invo

7条回答
  •  没有蜡笔的小新
    2020-11-28 03:00

    To overwrite a method means that whenever the method is called on an object of the derived class, the new implementation will be called.

    To hide a method means that an unqualified call to that name in the scope of this class (i.e. in the body of any of its methods, or when qualified with the name of this class) will now call a completely different function, requiring a qualification to access the static method of the same name from the parent class.

    More description Java Inheritance: Overwritten or hidden methods

提交回复
热议问题