Java--类初始化
1 package httpclient.demo; 2 3 public class StaticTest { 4 5 public static void main(String[] args) { 6 7 staticFunection(); 8 } 9 10 static StaticTest st = new StaticTest(); 11 12 static { 13 System.out.println("1"); 14 } 15 16 { 17 System.out.println("2"); 18 } 19 20 public StaticTest() { 21 // TODO Auto-generated constructor stub 22 System.out.println("3"); 23 System.out.println("a =" + a + ", b=" + b); 24 } 25 26 public static void staticFunection() { 27 System.out.println("4"); 28 } 29 30 int a = 110; 31 static int b = 112; 32 33 }