class Foo { int a; int b; int c = b; int var1; int var2; public Foo() { a = b; var1 = var2; var2 = var1; }}
您无法执行此
int a = b;*** 作的原因
b是,在创建对象时尚未定义,但是对象本身(即
this)及其所有成员变量都存在。
这是每个的说明:
int a = b; // Error: b has not been defined yet int a = this.b; // No error: 'this' has been defined ('this' is always defined in a class) int b; int c = b; // No error: b has been defined on the line before
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)