阅读背景:

Java中的'this'变量实际上是如何设置为当前对象的?

来源:互联网 

Consider:

class TestParent{
  public int i = 100;
  public void printName(){
    System.err.println(this); //{TestChild@428} according to the Debugger.
    System.err.println(this.i); //this.i is 100.
  }
}

class TestChild extends TestParent{
  public int i = 200;
}

public class ThisTest {
  public static void main(String[] args) {
    new TestChild().printName();
  }
}
class TestParent{
  public int i = 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: