1. 程式人生 > >5.7.3 顯式的靜態初始化

5.7.3 顯式的靜態初始化

public class Robot {
	private static String className = "Robot";
	private static int maxNum;
	static {
		System.out.println("init maxNum");
		maxNum = 10;
		System.out.println("finish init");
	}
	private String name;

	public static void show() {
		System.out.println("className:" + className + ",maxNum:" + maxNum);
	}

	public Robot() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Robot.show();
	}
}