interface is generally mainly used to describe individual methods, for example:
public interface eat{};
Implements class and interface docking keywords, for example:
public class cat implements eat{}
Features of the interface
1. The interface cannot be instantiated2. The implementing class must implement all methods of the interface
3. The implementing class can implement multiple interfaces
4. The variables in the interface are static constants
Interface classes have better features than abstract classes:
1. Can be multi-inherited2. Complete separation of design and implementation
3. More natural use of polymorphism
4. Easier to build a program framework
5. Easier to replace implementation
step:
Writing an InterfaceImplementing an Interface Implementing an Interface
Using Polymorphism
How interfaces implement polymorphism:
1. The interface is implemented as a method parameter2. The interface is implemented as a method return value