title: Enums - static and instance blocks
body: <p>I had learned that in Java the static block gets executed when the class is initialized and instance block get executed before the construction of each instance of the class . I had always seen the static block to execute before the instance block . Why the case is opposite for <code>enums</code> ?</p>
  
  <p>Can anyone please explain me the output of the sample code :</p>
  
  <pre><code>enum CoffeeSize {
  
      BIG(8), LARGE(10),HUGE(12),OVERWHELMING();
      private int ounces ;
  
      static {
          System.out.println("static block ");
      }
      {
          System.out.println("instance block");
      }
  
      private CoffeeSize(int ounces){
          this.ounces = ounces;
          System.out.println(ounces);
      }
      private CoffeeSize(){
          this.ounces = 20;
          System.out.println(ounces);
      }
  
      public int getOunces() {
          return ounces;
      }
  } 
  </code></pre>
  
  <p>Output:</p>
  
  <p>instance block<br>
  8<br>
  instance block<br>
  10<br>
  instance block<br>
  12<br>
  instance block<br>
  20<br>
  static block<br> </p>