public class TheOne {
public class TheInOne{
TheInOne(int n){
}
}
}public class TheTwo extends TheOne.TheInOne{
TheTwo(TheOne to,int n){
to.super(n);
}
}请问to.super(n);这个语法怎么解释?
如果吧super理解为是TheOne父类执行构造函数来绑定对象显然不通啊

解决方案 »

  1.   

    super就理解为是TheOne父类执行构造函数来绑定对象,
      

  2.   

    这个 to.supper()   在你的代码里面根本就不能够确定是 theOne 还是theTwo 的父类的构造函数,因为在你的代码里面只是一种对象引用调用,所有最后要取决你这个引用 TheTwo(TheOne to,int n){
            to.super(n);
        }TheOne  的实例,到底是子类(TheTwo)还是本身(TheOne).
      

  3.   

    public class TheOne {
        public class TheInOne{
            TheInOne(int n){
             System.out.println(n);
            }
        }
    }
    public class TheTwo extends TheOne.TheInOne{
        TheTwo(TheOne to,int n){
            to.super(n);
        }
    }
    public class TODO {
        public static void main(String[] args) {    
         TheOne to=new TheOne();
         TheTwo tt=new TheTwo(to,10); 
        }    
    }  主要我不理解的地方就是TheTwo和TheOne应该说是没有直接关系的,那为什么TheOne的对象调用super构造函数会是调用他内部类TheInOne的构造函数