1. What is an interface
(1) The interface is a collection of some method features, which are public by default, and properties can be modified with public static final.
(2) An interface can be considered as the secondary type of an object, and the parent class of the object is the primary type. For example, the main type of TreeMap is Abstractmap, followed by clonable and serializable
(3) The interface is a commitment to the customer, once made, cannot be withdrawn.
2. Why to use the interface
(1) Avoid hardcode dependent on another object, dynamically relying on another object.
(2) The guarantee of the pluggable nature
A. The relevance of the pluggable nature. A class is associated with another class, and only its interfaces need to be associated
B. The pluggable nature of the call. One object invokes another object's method
3. Common usage of interfaces
(1) Single-method interface: A method pointer similar to C. such as the Runnale interface
(2) Identity interface: an interface that does not have any properties and methods, such as serializable,java.rmi.remote, that tightly identifies the object as having a type
(3) Constant interface: You can declare some constants in the interface with public static final. This does not have to declare them again in the "inheriting" class. These classes are used like they do with their own constants, rather than having to define them over and over.
(4) Generalized interface
Interface for Java