1. class)
Visibility modifier:Public-It can be seen in all classes that can be imported using import in other packages.
Default Value-There is no modifier. It can be seen in the class in the same package, and cannot be imported using import in other packages.
Modifier:Final-Final state class, indicating that the class cannot be inherited
Abstract-Abstract class, cannot create an object
2. variable)
There are two types of variables in Java: Method variables and field variables.
Method variables can only use one modifier:Final-It indicates a constant and cannot be modified.
The modifier of the field variable is as follows:
Visibility modifier:Public-Visible in any class
Protected-Visible in subclass or in the same package
Private-Visible only in this class and not in subclass
Default Value-Visible in the same package. The subclass is not in the same package, and the subclass is invisible.
Modifier:Static-Static variables shared by all instances of the class
Final-Constant, cannot be modified after Definition
* Transient-Tells the compiler that this variable does not need to be permanently saved during class Object serialization.
* Volatile-It is pointed out that there may be multiple threads to modify this variable, and the compiler is required to optimize it to ensure that the modification of this variable can be correctly processed.
These two tapes are not very common, but they are also Java modifiers, and I am not very clear about them.
3. method)
Visibility modifier:Public-Visible in any class
Protected-Visible in subclass or in the same package
Private-Visible only in this class and not in subclass
Default Value-Visible in the same package. The subclass is not in the same package, and the subclass is invisible.
Modifier:Static-Static Method: you do not need to create an instance of the class to access the static method.
Final-Common method. All subclasses cannot overwrite the method, but can be overloaded.
Abstract-Abstract methods, which are not implemented in abstract classes
Native-For local methods, see Java Native Interface (JNI)
Synchronized-In multiple threads, when the synchronized method is called, other methods cannot call this method.
4. interface)
Visibility modifier:Public-Visible to all classes
Default-Visible in the same package
The variables in the interface must always be defined as"Public static finalInterface Name ", but can not contain these modifiers, the compiler by default is like this
Because the interface cannot have a direct instance, that is, it cannot be modified (final) or accessed through the instance (static ).
Methods In the interface can only be usedPublicAndAbstractModifier