Wednesday, 3 September 2014

JAVA working with Static Block

package com.mastermoin.java;

public class DemoRun {

       static
       {
              System.out.println("----static block @ start----");
       }
             
       public static void main(String[] args) {

              System.out.println("----begin----");    

       }
       static
       {
              System.out.println("----static block @ end----");
       }

}


_____________________________________________________________________
output

----static block @ start----
----static block @ end----
----begin----

All static block[s] is/are executed first and than after main method executed step by step

No comments:

Post a Comment