我正在尝试理解以下有效的 Java 代码。我有两个问题,在代码中进行了注释。
class C {
C x; //1.) why is something like x = new C(); not required here? Does this
//mean x refers to this current class of C?
int f;
void run(boolean b, int x) {
C y;
y = new C();
if (b) { this.bump(y,x); } //2.) Is "this" in this.bump necessary? Likewise,
//this.bump(this.y,x) would be equivalent right?
else { f = this.x.f + 1; }
}
void bump(C z, int j) {
z.f=j;
}
}
谢谢,抱歉这些基本问题