Circular dependency in java classes

后端 未结 5 1955
误落风尘
误落风尘 2020-11-28 09:23

I have the following classes.

public class B 
{
    public A a;

    public B()
    {
        a= new A();
        System.out.println(\"Creating B\");
    }
         


        
5条回答
  •  不知归路
    2020-11-28 09:53

    It isn't necessarily as easy as in your example. I believe solving this problem would be equal to solving the halting problem which -- as we all know -- is impossible.

提交回复
热议问题