下面的代码可用于打破 Java 中的循环依赖关系。
这是什么Pythonic方式?
interface A {
int A1();
}
class X implements A {
B b;
public int X1() {
b = B(this);
b.doSomething();
}
public int A1() { ... }
}
class B {
A a;
public B(A a) {
this.a = a;
}
public doSomething() {
//...
this.a.A1();
//...
}
}