Questions tagged «method-hiding»


16
覆盖vs隐藏Java-困惑
我对重写与隐藏在Java中有何不同感到困惑。谁能提供更多有关这些差异的详细信息?我阅读了Java教程,但是示例代码仍然让我感到困惑。 更清楚地说,我理解压倒一切。我的问题是,除了一个隐藏在实例级别而另一个隐藏在类级别之外,我看不到隐藏有什么不同。 查看Java教程代码: public class Animal { public static void testClassMethod() { System.out.println("Class" + " method in Animal."); } public void testInstanceMethod() { System.out.println("Instance " + " method in Animal."); } } 然后我们有一个子类Cat: public class Cat extends Animal { public static void testClassMethod() { System.out.println("The class method" + " in …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.