Skip to main content

java static 块

· One min read

背景

记录java的一些简单的语法

static 块

static block

8.7 Static Initializers
A static initializer declared in a class is executed when the class is initialized
(§12.4.2). Together with any field initializers for class variables (§8.3.2), static
initializers may be used to initialize the class variables of the class.

static 块会在类加载之后回调,在对象实例化之前