We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72d1e07 commit 57b6b95Copy full SHA for 57b6b95
src/com/blankj/csutom/ClassLoaderTest.java
@@ -0,0 +1,32 @@
1
+package com.blankj.csutom;
2
+
3
4
+//https://www.jianshu.com/p/5f468de3b806
5
6
+public class ClassLoaderTest {
7
8
+ public static void main(String[] args) {
9
+ System.out.println(A.j);
10
+// System.out.println(A.i);
11
+ }
12
13
+ static class A {
14
15
+ static int i = 2;
16
17
+ //可见类 A 是已经被准备过了,但是尚未初始化.
18
+// 准备阶段负责创建类静态字段,并把它初始化成默认值。这里的初始化,
19
+// 并不是调用代码的静态字段赋值语句和静态代码块,而是把每个静态字段初始化成 JVM 给定的初始值
20
+// 当然也有例外,字段被认为是 constant variable 时,也会在准备阶段被赋值
21
22
+ static final int j = 3;
23
24
+ static final int k;
25
26
+ static {
27
+ i = 3;
28
+ k = 3;
29
+ System.out.println("hello world");
30
31
32
+}
0 commit comments