class Parent{
private Child chlid;
Parent(){
child=new Child(this);
}
public void aa{}}class Child{
private Parent parent;
Child(Parent parent){
this.parent=parent;
} private void childaa(){
parent.aa();
}
}实例一个Child类,执行方法childaa()
有影响吗?
好像是循环!

解决方案 »

  1.   

    很早就是个题目了
    http://topic.csdn.net/u/20090715/18/4d9f25b1-ff0c-42eb-a0d1-9a9d98a45089.html
    看看这个帖子
      

  2.   

    如果Child改为:class Child{ 
    private Parent parent; 
    Child(Parent parent){ 
    this.parent=new parent(this); 
    }这就是循环了。 
      

  3.   

    实例一个Child类,   child 里面的 parent属性里的 child属性 和你实例化的不同。
                     但像你这样用的没有吧,  这是面试题目吧