title: Why does a static variable initialized by a method call that returns another static variable remains null?
body: <p>I simply don't understand the following code's execution flow:</p>
  
  <pre><code>class Test {
      static String s1 = getVal();
      static String s2 = "S2";
  
      private static String getVal() {
          return s2;
      }
  
      public static void main(String args[]) {
          System.out.println(s2); // prints S2
          System.out.println(s1); // prints null
      }
  }
  </code></pre>
  
  <p>It is supposed to print <code>S2</code> at second <code>println</code> statement. I am more interested in understanding why this happens rather than a solution.</p>