title: Static block execution before main method
body: <p>Does static block of class execute before the main method of same class? </p>
  
  <p>Example:</p>
  
  <pre><code>public class Example {
  
      static
      {
          System.out.println("hi");
      }
  
      public static void main(String[] args) {
  
          System.out.println("bye");
  
      }
  }
  </code></pre>
  
  <p>The output of this program is :</p>
  
  <blockquote>
    <p>hi</p>
    
    <p>bye</p>
  </blockquote>
  
  <p>My doubt is why the output was not:</p>
  
  <blockquote>
    <p>bye</p>
  </blockquote>