Called class members
: class attributes
and class methods
.
We can use ClassName.StaticField
and ClassName.StaticMethod
to access them.
They don’t belong to any instance, so we can’t use this.StaticMember
, super.StaticMember
.
Note: main
method is static, so JVM doesn’t create a instance of the class where main
is in. As a result, main
can’t access non-static members of the class unless create instance of that class.
static block: when the class is loaded, the static block in that class is executed, and executed for only one time. Usually used to initialized the class.