title: Can static method access non-static instance variable?
body: <p>So my understanding was that you can't use static method to access non-static variables, but I came across following code.</p>
  
  <pre><code>class Laptop {
    String memory = "1GB";
  }
  class Workshop {
    public static void main(String args[]) {
      Laptop life = new Laptop();
      repair(life);
      System.out.println(life.memory);
      }
    public static void repair(Laptop laptop) {
      laptop.memory = "2GB";
    }
  }
  </code></pre>
  
  <p>Which compiles without errors.</p>
  
  <p>So isn't </p>
  
  <pre><code>public static void repair(Laptop laptop) {
  laptop.memory = "2GB";
  }
  </code></pre>
  
  <p>accessing String memory defined in class Laptop, which is non-static instance variable? </p>
  
  <p>Since the code compiles without any error, I'm assuming I'm not understanding something here. Can someone please tell me what I'm not understanding?</p>