title: How does the static modifier affect this code?
body: <p>Here is my code: </p>
  
  <pre><code>class A {
      static A obj = new A();
      static int num1;
      static int num2=0;
  
      private A() {
          num1++;
          num2++;
      }
      public static A getInstance() {
          return obj;
      }
  }
  
  public class Main{
      public static void main(String[] arg) {
          A obj = A.getInstance();
          System.out.println(obj.num1);
          System.out.println(obj.num2);
      }
  }
  </code></pre>
  
  <p>The output is <code>1 0</code>, but I can't understand.</p>
  
  <p>Can somebody explain it to me?</p>