java中父类构造方法中的this指向谁

public class Test { 

    public Test() { 
    } 
     
    public static void main(String[] args) { 
        new s(); 
    } 


class F{ 
    public F() { 
        System.out.println(this.getClass().getName()); 
        this.f1(); 
    } 
    public void f1() { 
        System.out.println(1234); 
    } 


class s extends F{ 
    public s() { 
         
    } 
     
    public void hello() { 
        System.out.println(123); 
    } 

}

this指向谁 //运行结果是 s子类

但是又输出1234

解释:https://www.oschina.net/question/74811_123958

猜你喜欢

转载自www.cnblogs.com/CrisZjie180228/p/9029146.html
今日推荐