1, abstract class:abstract
1. As long as there are one or more abstract methods, it must be declared as an abstract class with abstract;
2. There can be specific implementation methods in abstract classes;
3. There may be no abstract methods in abstract classes;
4. The abstract method in an abstract class must be implemented by its subclass. If the subclass is not implemented, the subclass will continue to be an abstract class.
5. Abstract classes cannot be instantiated, but concrete implementation methods in abstract parent classes can be called by subclass instances pointed to by abstract parent classes; usually as a default behavior;
6. To use methods in abstract classes, a subclass must inherit from this abstract class and implement abstract methods in abstract classes, and call them through instances of subclasses;
2. Interface: interface
1. There can be member variables in the interface, and the member variables in the interface must be defined and initialized;
2. The member methods in the interface can only be method prototypes and cannot have method bodies;
3. The member variables and member methods of the interface can only be public (or not written by default). The effect is the same, and they are both public.
4. All classes that implement interfaces must implement methods in the interface (the implementation of the parent class is also counted. Generally, there is a method of implementing a method with little opposite sex in the interface through the base class to act as an adapter)
Three, keywords: final
1. Can be used to modify: member variables, non-abstract classes (cannot appear at the same time as abstract), non-abstract member methods, and method parameters
2. Final method: cannot be rewritten by subclass methods, but can be inherited;
3. Final class: means that the class cannot be inherited and has no subclasses; methods in final class cannot be inherited either.
4. Final variable: represents a constant, which can only be assigned once, and cannot be modified after assignment. Final variable must be defined and initialized;
5. Final cannot be used for modifying construction methods;
6. Final parameters: Only use this parameter, and the value of this parameter cannot be modified;
Four, keywords: static
1. Member variables and member methods can be modified, but classes and constructor methods cannot be modified;
2. Member variables and member methods modified by static are independent of any object of this class. That is, it does not depend on class-specific instances and is shared by all instances of the class.
3. Static variables and static methods are generally accessed directly through class names, but they can also be accessed through class instances (this access method is not recommended)
4. Static variables and static methods are also suitable for Java access modifiers. Static variables and static methods modified with public can be accessed directly through the class name anywhere, but static variables and static methods modified with private can only be accessed in the declared methods of this class and static blocks, but cannot be accessed with this because this is a non-static variable.
Five, static and final use at the same time
1. Static final is used to modify member variables and member methods, which can be simply understood as "global constants"!
2. For variables, the representation cannot be modified once the value is given and can be accessed through the class name.
3. For methods, the representation cannot be overridden and can be directly accessed through the class name.
6. Why can't abstract and static be added at the same time before a method?
static is static, which means something that has been determined at compile time. Of course, it cannot be abstract (dynamic), that is something that can only be determined at runtime.
The above content is the Java final static abstract keyword introduced to you by the editor. I hope it will be helpful to everyone!