参见英文答案 > What is the meaning of “this” in Java? 18个
当ai遇到this关键字时,我正在研究Java中的方法覆盖.在互联网和其他来源上搜索了很多这个,我得出结论,当实例变量的名称与构造函数相同时,使用该关键字
参数.我是对还是错?
class Foo
{
     private int bar; 
     public Foo() {
          this(42); // invoke parameterized constructor
     }
     public Foo(int bar) {
         this.bar = bar; // disambiguate 
     }
     public void frob() {
          this.baz(); // used "just because"
     }
     private void baz() {
          System.out.println("whatever");
     }
}
  翻译自:https://stackoverflow.com/questions/8708216/use-of-this-keyword-in-java