整个过程
- java内存分析:
![]()
- 类的加载过程
![]()
- 类加载的理解
![]()
案例如下
- 案例代码:
public class Test04 {
public static void main(String[] args) {
A a = new A();
System.out.println(a.m);
}
}
class A {
static {
System.out.println("A类静态代码块初始化");
m = 300;
}
static int m = 100;
public A() {
System.out.println("A类的无参构造初始化");
}
}
- 运行结果如下:
A类静态代码块初始化
A类的无参构造初始化
100
- 狂神说的内存分析图:
![]()



