当前位置: 代码迷 >> J2SE >> this 与 方法重写 的烦恼!
  详细解决方案

this 与 方法重写 的烦恼!

热度:39   发布时间:2016-04-24 12:19:16.0
this 与 方法重写 的烦恼!!!求助!!
Java code
class Father{     private void hello(){           System.out.println("hello father!");     }     public void f1(){           this.hello();     }}class Son extends Father{     public void hello(){           System.out.println("hello son!");     }}public class Test{     public static void main(String[] args){         student1.f1();     }}


结果会输出:hello father!;
这是怎么回事呢?

------解决方案--------------------
继承了父类的方法包括私有的
  相关解决方案