Whether the corresponding modifiers for classes, methods, member variables, and local variables can be used
Modifier |
Class |
Member adapting |
Construction method |
Member variables |
Local variables |
Abstract (abstracted) |
√ |
√ |
- |
- |
- |
Static (statically) |
- |
√ |
- |
√ |
- |
Public (Common) |
√ |
√ |
√ |
√ |
- |
Protected (Protected) |
|
√ |
√ |
√ |
- |
Private (privately) |
- |
√ |
√ |
√ |
- |
Synchronized (synchronous) |
- |
√ |
- |
- |
- |
Native (local) |
- |
√ |
- |
- |
- |
Transient (temporary) |
- |
- |
- |
√ |
- |
Volatie (volatile) |
- |
- |
- |
√ |
- |
Final (do not change) |
√ |
√ |
- |
√ |
√ |
|
|
|
|
|
|
|
class modifier |
Public |
can be accessed from other classes |
Abstract |
Cannot be instantiated, can contain abstract methods, abstract methods are not implemented, no specific functions, can only derive sub-classes |
Final |
Subclass can no longer be declared |
constructor Modifier |
Public |
can be accessed from all classes |
Protected |
can only be accessed from its own class and its subclasses |
Private |
can only be accessed in this class |
Domain / member Variable modifiers |
Public |
can be accessed from all classes |
Protected |
can only be accessed from this class and its subclasses |
Private |
It can only be accessed from this class |
Static |
Only one domain value exists for all instances of the class |
Transient |
is not part of an object's persistent state |
Volatile |
Can be modified by an asynchronous thread |
Final |
It must be given an initial value and cannot be modified |
Local Variables modifier |
Final |
It must be given an initial value and cannot be modified |
Method Modifiers |
Public |
It can be accessed from all classes |
Protected |
It can only be accessed from this class and its subclasses |
Private |
It can only be accessed from this class |
Abstract |
No method body, belongs to an abstract class |
Final |
Subclasses cannot overwrite it |
Static |
is bound to an instance of the class itself rather than the class |
Native |
This method is implemented by other programming languages |
Asnchronized |
Before a thread calls it, it must first add the |
Java Getting Started concept personal understanding of access modifiers