class User{
private String name;
private int count;
static{
User.count = 0;
System.out.println("static initializer");
}
{
System.out.println("instance initializer");
}
public class User(String name){
this.name = name;
User.count++;
System.out.println("constructor");
}
public static void getInfo(){
System.out.println("# of instances: "+User.count);
}
}
public class MyInitializer{
public static void main(String[] args){
User.getInfo();
User.getInfo();
User tom = new User("tom");
User.getInfo();
User bob = new User("bob");
User.getInfo();
}
}