title: How does the "this" keyword in Java inheritance work?
body: <p>In the below code snippet, the result is really confusing.</p>
  
  <pre><code>public class TestInheritance {
      public static void main(String[] args) {
          new Son();
          /*
          Father father = new Son();
          System.out.println(father); //[1]I know the result is "I'm Son" here
          */
      }
  }
  
  class Father {
      public String x = "Father";
  
      @Override
      public String toString() {
         return "I'm Father";
      }
  
      public Father() {
          System.out.println(this);//[2]It is called in Father constructor
          System.out.println(this.x);
      }
  }
  
  class Son extends Father {
      public String x = "Son";
  
      @Override
      public String toString() {
          return "I'm Son";
      }
  }
  </code></pre>
  
  <p>The result is</p>
  
  <pre><code>I'm Son
  Father
  </code></pre>
  
  <p>Why is "this" pointing to Son in the Father constructor, but "this.x" is pointing to "x" field in Father. How is the "this" keyword working?</p>
  
  <p>I know about the <em>polymorphic</em> concept, but won't there be different between [1] and [2]? What's going on in memory when <em>new Son()</em> is triggered?</p>