Modifiers that can be attached to variables and methods. It can be called without instantiation. Also, even if you instantiate the original class, static variables and static methods are managed in one place. (= Each instance does not have its own static variable.) Only static variables or static methods can be called from static methods.
You can also define a ** static initializer ** in the class that defines what happens when the class file is loaded.
static initializer
class A {
static {
//processing
}
}
private: accessible from the same class (Default): Accessable from classes in the same package protected: accessible from the same package or subclass public: accessible from any class
Recommended Posts