import java.awt.Button;
public class A {
private Button b ;
public Button getB() {
return b;
}
public void setB(Button b) {
this.b = b;
}
A(){
b = new Button();
B b = new B(this);
}
public static void main(String[] args){
new A();
}
}
class B {
A past = new A();
B(A p){
this.past = p;
}
} 不太明白 為什么這段代碼會(huì)報(bào)堆棧溢出的錯(cuò)誤,,,
1 回答

夢(mèng)里花落0921
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超6個(gè)贊
new A() 時(shí)需要newB() new B()時(shí)需要newA() 死循環(huán)了
添加回答
舉報(bào)
0/150
提交
取消