最佳答案
可能的复制品:
静态初始化块
考虑以下 密码:
public class Test {
{
System.out.println("Empty block");
}
static {
System.out.println("Static block");
}
public static void main(String[] args) {
Test t = new Test();
}
}
我们知道,首先执行 静电干扰块,然后执行 空荡荡的块。但问题是,我从来没有能够理解一个 空荡荡的块的真正实用性。有人能举个真实的例子吗