1.final: The final, immutable------are less likely to be used alone
1) modifier variable: variable cannot be changed
2) Modification Method: Method cannot be overridden
3) Modifier class: class cannot be inherited
2.static Final: Constant, high application rate
1) must declare simultaneous initialization
2) accessed through the class name and cannot be changed.
3) Recommended: Constant name All letters are capitalized, multiple words separated by _
4) compiler directly replaces constants with specific values at compile time, high efficiency
3. Abstract Method:
1) modified by the abstract
2) Only method definition, no method specific implementation (not even {})
4. Abstract class:
1) modified by the abstract
2) classes that contain abstract methods must be abstract classes, classes that do not contain abstract methods can also be declared abstract-----I'd like to
3) Abstract classes cannot be instantiated
4) An abstract class is a subclass that needs to be inherited:
4.1) overriding all abstract methods--------General general usage
4.2) also declared as abstract class----------infrequently used
5) Meaning of abstract class:
5.1) Encapsulating attributes and behaviors common to subclasses-------------code reuse
5.2) provides a uniform type for all subclasses---------upward styling
5.3) can contain abstract methods, providing a uniform entry for all subclasses the implementation of each subclass differs, but the entry is consistent
5. Interface:
Class and class-----------------inherit extends
Interface and interface-------------inherit extends
Class and interface---------------implementation implements
1) is a standard, normative------------the formulation of the party
Following this standard, you can do something------------API
2) interface is a data type (reference type)
3) defined by interface
4) can only contain constants and abstract methods
5) interface cannot be instantiated
6) interfaces need to be implemented, implementing classes: All abstract methods in the interface must be rewritten
7) A class can implement a number of interfaces, separated by commas, and if inherited and implemented, should inherit the implementation of the first
8) interface can inherit interface
Interfaces are abstract classes that are completely abstract-----correct
Example:
New Inter1 (); Compile error
Inter1 O1; That's right
Interface inter1{
public static final int NUM = 5;
public abstract void Show ();
int COUNT = 5; Default public static final
void Test (); Default public abstract
Double PI; Compile errors, constants must be declared at the same time
void Say () {}//Compilation error, abstract method cannot have method body
}
I am a beginner, if the update is not good, welcome the Great God pointed out, thank you!
More exciting after the update, reprinted annotated!
java-modifier words, abstract classes, abstract methods