title: When Initializing object, instance variable not initialized always?
body: <p>The following code produces NullPointerException -</p>
  
  <pre><code>public class MyClass {
  
      static MyClass instance= new MyClass(); // line 3
      static Boolean have_Instance = true;
      Boolean inst_Avail=have_Instance; // line 5
  
      Boolean isInstAvail(){
          return inst_Avail;
      }
  
      public static void main(String[] args) {
          System.out.println(instance.isInstAvail() ? "Instance is there.":""); // gives java.lang.NullPointerException
      }
  
  }
  </code></pre>
  
  <p>If I move <code>line 3</code> to after <code>line 5</code>, it runs fine. How does the order matter here? Shouldn't instantiation of a class set iVar values everytime?</p>