我正在討論在下面的示例中創建了多少個對象。我相信應該有5個,但我不太確定。創建了多少個對象 - Java
class Test {
int a; int b;
Test(){
}
Test(int a_, int b_){
a=a_; b=b_;
}
Test(Test r){
a=r.a; b=r.b;
}
void povecaj() {
a++; b++;
}
Test dodaj(Test r)
Test t = new Test(a+r.a, b+r.b);
return t;
}
}
// ...
Test t1 = new Test();
Test t2 = new Test(1, 2);
t1.povecaj();
Test t3 = new Test(t2);
t1 = t1.dodaj(t3);
t2 = t3;
使用調試器。 ... – redFIVE
4. 13個字符去。 –
@MarkSeygan 4個對象? – user3047285