public class StaticInitialiser {
final String instanceName ;
    public StaticInitialiser(String name) { this.instanceName=name;System.out.println(name + ".constructor"); }
    static { System.out.println("static initialiser"); }
    { System.out.println("instance initializer"); }
    static { System.out.println("2nd static initialiser"); }
    { System.out.println("2nd instance initialiser called"); }
    public static void main( String[] args ) {
        new StaticInitialiser ("one");
        new StaticInitialiser ("two");
  }
}

oo_java_static_initialisers.txt ยท Last modified: 2011/11/27 09:15 by Administrator