Classes (Class) ([12] [~34]) |
Method ([1234] [+] [~67]) |
Public |
Can be used by all classes (requires the same class name as the file name) |
Public |
4. Can be accessed in the global scope |
Default (Empty) |
can only be accessed by other classes of the same package |
Protected |
3. Can be accessed by sub-classes of different packages |
Abstract |
Abstract class, cannot create instance, only as parent class |
Default (Empty) |
2. Can be accessed by other classes of the same package |
Final |
will not be able to be used as the parent class |
Private |
1. Can only be accessed within the current class |
Member variables ([1234] [+] [~]) |
[1] Static |
Without this adornment, you can only invoke it through an instance. |
Public |
4. Can be accessed in the global scope |
Abstract |
Classes with abstract methods can only be defined as abstract classes |
Protected |
3. Can be accessed by sub-classes of different packages |
Final |
Subclasses are not allowed to overwrite the final method of the parent class |
Default (Empty) |
2. Can be accessed by other classes of the same package |
Constructor (no return value declaration) |
Private |
1. Can only be accessed within the current class (common) |
Public |
4. Global scope accessible (constant) |
[1] Static |
Through its adornments, it can be called through a class or instance |
Protected |
3. Can be accessed by sub-classes of different packages |
Final |
Re-assigning a value to the final variable is not allowed |
Default (Empty) |
2. Can be accessed by other classes of the same package |
Initialize block {} (executed before execution of the constructor) |
Private |
1. Can only be accessed within the current class |
Static |
(Cannot initialize an instance variable) executes during the class initialization phase, rather than when the object is created. |
Private modifies all constructors of this class, and subclasses cannot invoke the class constructor, and thus cannot inherit. This class will not be able to create an instance directly, but you can return the instance and control it by creating a (public static class method) (P174) |
Default (Empty) |
The This reference cannot be used in static decorated methods, so static decorated methods cannot access ordinary members that do not use the static adornment |
Inner class ([1234] [+] [~67]) |
The final decorated member variable must explicitly specify an initial value. (1. Class variable: The initial value must be specified in the static initialization module or when declaring the class variable; 2. Instance variable: The initial value must be specified in a non-static initialization module, declaring the instance variable, or the constructor |
Public |
4. Can be accessed in the global scope |
Protected |
3. Can be accessed by subclasses of different packages of external classes |
Default (Empty) |
2. Can be accessed by other classes of the same package as the external class |
Private |
1. Can only be accessed within the current external class |
Static |
Non-static inner classes cannot have static members |
The final modifier local variable can be specified at the time of declaration, or it can be assigned an initial value in subsequent code, but only once. |
Abstract |
Abstract class, cannot create instance, only as parent class |
Final |
will not be able to be used as the parent class |
Final modified formal parameter, the form is called when the method is invoked by the system to complete the initialization according to the parameters passed in, so it cannot be assigned a value |
The internal class defined in the interface uses the public static modifier by default |
The local inner class (defined in the method) cannot use the access control modifier |
The final modification of reference variables only guarantees that the address of the variable reference is unchanged |
All local variables cannot use the static modifier |
Abstract modified classes can only be inherited abstract cannot and static/private modify a method at the same time |
Anonymous inner class: New Implementation interface () | Parent class Constructor (argument) {} |
Anonymous inner classes are suitable for creating classes that only need to be used once |
The abstract modified method is defined without {}, and only methods that do not implement the abstract adornment must be provided by the subclass to provide the implementation (override) |
J8 before the anonymous/local inner class can access only the final local variable J8 automatically uses the final decoration for the local variable that it accesses |
Enum class enum (same as class, interface status) |
|
|
Inherited |
One or more interfaces can be implemented |
|
|
The default inherits Java.lang.Enum instead of object, so the enumeration class cannot display inheritance from other parent classes |
|
|
Enum class implements the Java.lang.Serializable and java.lang.Comparable two interfaces |
|
|
Use Enume-defined, non-abstract enum classes by default with final |
|
|
Constructors |
You can only use private (can omit) access control characters |
|
|
An instance of an enumeration class must appear listed (', ' separated) in the first row of the enumeration class, or the enumeration class will never produce an instance. When you list these instances, the system automatically adds a public static final decoration without the programmer's display additions. |
|
|
Values () method |
Easy traversal of all enumerated values |