static
is used to declare nested classes, static methods, fields, initialization blocks, and static imports.Static fields and methods are class members, not instance members, which means they can be accessed through the class name. The code within a static block or method can only access other static members. Static fields do not participate in serialization.
Static methods use early binding, meaning the call to a specific method is resolved at compile time, and neither overloading nor overriding in subclasses applies.
A static initialization block executes in a thread-safe manner, exactly once, immediately after the class is loaded by the class loader. Initializers for static fields are executed in an implicit static block. There can be multiple blocks, and they execute in the order they are declared.
static import
allows the static members of classes to be imported into a .java
file.