What is method hiding in Java? Even the JavaDoc explanation is confusing
问题 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 invoked is the one in the subclass. doesn\'t ring a bell to me. Any clear example showing the meaning of this will be highly appreciated. 回答1: public class Animal { public static void foo() { System.out.println("Animal"); } } public class Cat extends Animal { public static void foo() { // hides Animal.foo() System.out.println("Cat"); } } Here, Cat