title: How the output of program came?
body: <p>The output of following program is:</p>
  
  <blockquote>
  <pre><code>superstatic block
  static blockn0  
  inmain  
  super constructor  
  constructor
  </code></pre>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code> class StaticSuper{
      static {
             System.out.println("superstatic block");
      }
      StaticSuper(){
             System.out.println("super constructor");
      }
   }
  
   public class StaticClassExample extends StaticSuper{
        static int rand;
  
        static {
             rand =(int) (Math.random() * 6);
             System.out.println("static blockn" + rand);
        }
        StaticClassExample(){
             System.out.println("constructor");
        }
  
        public static void main(String[] args) {
             System.out.println("inmain");
             StaticClassExample st= new StaticClassExample();
        }
   }
  </code></pre>
  
  <p>Why "inmain" is printed third though it is first in the <code>main()</code>?  Please explain me the meaning of:</p>
  
  <pre><code>static {
   // some lines
  }
  </code></pre>
  
  <p>in the class. </p>