title: Why do two programs have forward referencing errors while the third does not?
body: <p>The following does not compile, giving an 'illegal forward reference' message:</p>
  
  <pre><code>class StaticInitialisation {
  
      static
      {
          System.out.println("Test string is: " + testString);
      }
  
      private static String testString;
  
      public static void main(String args[]) {
          new StaticInitialisation();
      }
  }
  </code></pre>
  
  <p>However, the following does compile:</p>
  
  <pre><code>class InstanceInitialisation1 {
  
      {
          System.out.println("Test string is: " + this.testString);
      }
  
      private String testString;
  
      public static void main(String args[]) {
          new InstanceInitialisation1();
      }
  }
  </code></pre>
  
  <p>But the following does not compile, giving an 'illegal forward reference' message:</p>
  
  <pre><code>class InstanceInitialisation2 {
  
          private String testString1;
  
      {
          testString1 = testString2;
      }
  
      private String testString2;
  
      public static void main(String args[]) {
          new InstanceInitialisation2();
      }
  }
  </code></pre>
  
  <p>Why do StaticInitialisation and InstanceInitialisation2 not compile, while InstanceInitialisation1 does?</p>