public class Test {
public static void main(String[] args) {
f1();
}
static Test t = new Test();
static{
System.out.println("1");
}
{
System.out.println("2");
}
Test(){
System.out.println("3");
System.out.println("a="+a+",b="+b);
}
public static void f1() {
// TODO Auto-generated method stub
System.out.println("4");
}
int a = 110;
static int b = 112;
}
结果:
2
3
a=110,b=0
1
4
小结:
类加载四种方式:
调用构造器,Class.forName(),调用静态属性,调用静态方法;