Summary of modifiers in Java:
Access Control modifiers
Function: Used to control the visible range of modified variables, methods, classes.
Public has the highest access level, followed by protected, default, and private.
member variables and member methods can be one of 4 access levels: public, protected, default, or private.
When there is an inheritance relationship, the parent class cannot be private because the subclass cannot inherit
The top-level class can be exposed or default, and the top-level class cannot be protected and private decorated.
Local variables cannot be decorated with access control modifiers.
The permissions modifiers that can be accessed under different packages are only: pulbic and protected, but protected must have an inherited relationship to be accessible.
Abstract modifier
Abstract classes cannot be instantiated.
Abstract classes can have no abstract methods, but classes that contain abstract methods must be defined as abstract methods.
If a subclass does not implement all of the abstract methods in the parent class, the subclass must also be defined as an abstract class.
Abstract classes cannot be defined as private, final, and static types.
There is no abstract construction method.
Abstract methods have no method body, and if a method has no method body, then the method must be declared as an abstract method.
When a non-abstract class inherits an abstract class, all abstract methods in the abstract class must be implemented.
Final modifier
The final variable must be explicitly initialized and can only be assigned one value at a time
The variable cannot be re-assigned when final modifies the base type variable
When the final modifier references a type variable, the variable cannot be re-directed to another object
The final modified method is the ultimate method, and the method cannot be overridden
Private type methods are implicitly considered the final method, and therefore cannot be overridden by a quilt class
The final decorated class is the ultimate class and cannot be inherited
static modifier
If a static method or variable is declared, the value is placed in the method area because the method area is a data-sharing area, so no matter what variable accesses it, it is the same copy.
Instance methods and instance variables cannot be accessed directly in a static method.
The This and Super keywords cannot be used in static methods.
Static methods cannot be modified by an abstract.
Static member variables can be accessed using either the class name or the object, and non-static member variables can only be accessed using the object.
Static functions can access static members directly, but they cannot access non-static members directly., non-static functions can access both static and non-static members.
Static code blocks can only be executed once when the class is loaded. The different static method code blocks in the class are executed sequentially in the order in which they appear in the class.
When multiple modifiers are connect prompt, the order of the modifiers can be reversed, but as a universally adhered coding norm, the access control modifier is usually placed first, followed by the static or Abstact modifier, followed by other modifiers
Permission modifiers in Java