title: Static block in Java not executed
body: <pre><code>class Test {
      public static void main(String arg[]) {    
          System.out.println(&quot;**MAIN METHOD&quot;);
          System.out.println(Mno.VAL); // SOP(9090);
          System.out.println(Mno.VAL + 100); // SOP(9190);
      }
  
  }
  
  class Mno {
      final static int VAL = 9090;
      static {
          System.out.println(&quot;**STATIC BLOCK OF Mno\t: &quot; + VAL);
      }
  }
  </code></pre>
  <p>I know that a <code>static</code> block executed when class loaded. But in this case the instance variable inside class <code>Mno</code> is <code>final</code>, because of that the <code>static</code> block is not executing.</p>
  <p>Why is that so? And if I would remove the <code>final</code>, would it work fine?</p>
  <p>Which memory will be allocated first, the <code>static final</code> variable or the <code>static</code> block?</p>
  <p>If due to the <code>final</code> access modifier the class does not get loaded, then how can the variable get memory?</p>