Tuesday, February 28, 2012

Static initialization block

Static Initialization Block


package com.anicehumble;


public class MainClass {

 public static void main(String[] args) {  
 
  System.out.println("Hello");
  Great.test();
  Great.test();
      
 }
}

package com.anicehumble;

public class Great {

 static 
 {
  System.out.println("One Time");
 }
 
 public static void test()
 {
  System.out.println("Test");
 }
 
}

Output:
Hello
One Time
Test
Test


No comments:

Post a Comment