Access modifiers:
Default, public, private, protected
Non-access modifiers
Static
Static methods, static variables
Final
Final variable:
The final variable can be displayed initialized and can be initialized only once. A reference to an object that is declared final cannot point to a different object. But the data in the final object can be changed. This means that the final object reference cannot be changed, but the value inside can be changed.
The final modifier is typically used with the static modifier to create a class constant.
Final method:
The final method in a class can inherit from a subclass, but cannot be modified by a quilt class
The primary purpose of declaring the final method is to prevent the method from being modified
Final class
Final class cannot be inherited
Abstrac modifier
Abstract class:
Abstract classes cannot be instantiated, and the only purpose of declaring an abstract class is to augment the class in the future.
A class cannot be both abstract and final decorated
Abstract method:
An abstract method is a method that does not have any implementation, and the specific implementation of the method is provided by the subclass.
Abstract methods cannot be declared as final and abstract
Any subclass that inherits an abstract class must implement all the abstract methods of the parent class, unless the subclass is also an abstract class
If a class contains abstract methods, then the class must be an abstract class, but abstract classes do not necessarily contain abstract methods.
Synchronized
The method of synchronized keyword declaration can only be accessed by one thread at a time. The synchronized modifier can be applied to four access modifiers.
Transient
When a serialized object contains an instance variable that is transient decorated, the Java Virtual Machine (JVM) skips that particular variable.
Volatile:
A decorated member variable forces the value of the member variable to be reread from shared memory each time it is accessed by the thread. Also, when a member variable changes, the thread is forced to write the value of the change back to the shared memory. So at any moment, two different threads always see the same value for a member variable.
A volatile object reference may be null.
Java Learning (c)---modifiers