Ads Sponsored By Google :)

Sunday, 27 January 2013

static block in java class initailizer|initialization Significance of with example|code|execution flow|tutorial

static block in java java stack block static block stack block java static block in java class use of static block in java static initialization block java class static block java static initializer block static block in java example
static Block in java class example java static initializer block example static code block in java class static block in java code static block in java execution static block in java tutorial static block in java with example static block in java execution flow static code block in java significance of static block in java

    Static Block   :

          Static block is execution is started when any class contains static block then static block 
          is loaded into memory. 
         That means before the main method is called static block is used for Initialization of static 
         members.Static block is not inside any method and this block will get executed only once 
          while loading the class.

      Example :
          public class SBDemo {
                  System.out.println("this is static block");
                  public static void main(String args[]){
                    System.out.println(“this is main method”);

           From the above program we can say that static block execution would take first then it    
     will execute or initialize the data members in main method. Then if we run this program first it   
     will print this is static block then it will print this is main method.

1 comment:

  1. Static block in java

    Thanks for sharing this post, really this post is very simple and easy.