One, abstract class: Abstract
1, as long as there is one or more abstract methods of the class, must be declared abstract as an abstraction class;
2, the abstract class can have specific implementation methods;
3, there can be no abstract method in the abstract class;
4, an abstract method in an abstract class must be implemented by its subclass, and if the subclass is not implemented, the subclass continues to be an abstract class
5, an abstract class cannot be instantiated, but it is possible to invoke the specific implementation method in an abstract parent class by referring to a subclass instance of the abstract parent class, usually as a default behavior;
6, to use a method in an abstract class, you must have a subclass that inherits from the abstract class and implements the abstract method in the abstract class, which is invoked by an instance of the subclass;
Two, interface: interface
1, the interface can have member variables, and the member variables in the interface must be defined initialization;
2, the member method in the interface can only be a method prototype, can not have method main body;
3, the member variables and member methods of the interface can only be public (or not written by default), as the effect is public
4, the implementation of the interface of the class must all implement the methods in the interface (the implementation of the parent class is also counted, generally through the base class to implement the interface of the opposite sex is not a way to do as an adapter)
Third, the key word: final
1, can be used to modify: member variables, non-abstract classes (not present with abstract), Non-abstract member methods, and method parameters
2,final method: Can not be overridden by the method of quilt class, but may be inherited;
3,final class: Indicates that the class cannot be inherited, there are no subclasses, and methods in the final class cannot be inherited.
4,final variable: Represents a constant that can only be assigned once and cannot be modified after assignment. Final variable must define initialization;
5,final can not be used to modify the construction method;
6,final parameter: Only this parameter can be used, the value of the parameter cannot be modified;
Four, Keywords: static
1, you can modify the member variable and the member method, but you cannot modify the class and construct the method;
2, the member variables and member methods that are modified by static are independent of any object of the class. That is, it does not rely on class-specific instances and is shared by all instances of the class
3,static variables and static methods are generally accessed directly through the class name, but can also be accessed through instances of the class (this access is not recommended)
4,static variables and static methods are also suitable for Java access modifiers. Static variables and static methods, decorated with public, can be accessed directly from the class name anywhere, but with the static and static methods decorated with private, can only be accessed in this class of methods and static blocks declared, but cannot be accessed with this, because this is a non-static variable.
Five, static and final simultaneous use
1,static final is used to decorate member variables and member methods, which can be easily understood as "global constants"!
2, for a variable, it means that once the value is not modifiable, it can be accessed through the class name.
3, for methods, are not overwritten, and can be accessed directly through the class name.
Why can't a method add both abstract and static at the same time?
Static is statically, something that has been determined at compile time, certainly not abstract (dynamic), that is what the runtime can determine
The above content is small series to introduce the Java final static abstract keyword, I hope to help you!