类初始化步骤

来源:互联网 发布:金庸小说排名 知乎 编辑:程序博客网 时间:2024/05/31 05:27
public class Instace1 {
static{
System.out.println(1);
}
{
System.out.println(2);
}


public Instace1() {
System.out.println(3);
}


{
System.out.println(4);
}


public static void main(String[] args) {
new Instace1();
new Instace1();
}

}

输出结果:

1
2
4
3
2
4
3

原创粉丝点击