title: I am working on static and instance variables in Java, where I couldn't understand the output of the code
body: <pre><code>package java_course;
  
  public class staticVsInstance {
  
      static int x = 11; 
      private int y = 33; 
  
      public void method1(int x) {
          staticVsInstance t = new staticVsInstance();
          System.out.println("t.x "+t.x + " " +"t.y  "+ t.y + " " +"x "+ x + " "+"y " + y);
          this.x = 22;
          this.y = 44;
          System.out.println("t.x "+t.x + " " +"t.y  "+ t.y + " " +"x "+ x + " "+"y " + y);
      }
  
      public static void main(String args[]) {
  
          staticVsInstance obj1 = new staticVsInstance();
  
          System.out.println(obj1.y);
          obj1.method1(10);
          System.out.println(obj1.y);
      }
  }
  </code></pre>
  
  <p>and the output is</p>
  
  <pre class="lang-none prettyprint-override"><code>33
  t.x 11 t.y  33 x 10 y 33
  t.x 22 t.y  33 x 10 y 44
  44
  </code></pre>
  
  <p>Does <code>this.y</code> refer to <code>obj1.y</code> or <code>t.y</code> in <code>method1</code>?</p>
  
  <p>Why hasn't changing <code>this.y</code> any affect on <code>t.y</code>?</p>