Friday 18 January 2013

static in java

//In this program initially it executes static block so it prints Hello I am before main and then it moves to main and print Hello I am in main then it prints Hello I am After main
public class HelloWithStatic 
{
 static
 {
  System.out.println("Hello I am before main");
  main(null);
  System.out.println("Hello I am After main");
  System.exit(0);
 }
 public static void main(String[] args) 
 {
  System.out.println("Hello I am in main");
 }
}

No comments:

Post a Comment