Fourth chapter interface One, interface
1. Interfaces can be viewed as a special "abstract class".
2. Interfaces have better features than abstract classes
3. Can be multiple inheritance
4. Design and achieve complete separation
5. More natural use of polymorphism
Second, the interface convention
1. The interface represents a convention that is embodied in interface names and annotations (some interfaces have only names, and methods are implemented by annotations)
2. The interface is a capability: it is embodied in the method of the interface
3. Interface-oriented programming: interface-oriented conventions in programming without regard to implementation.
4. Interface-oriented programming: care about the capabilities of the implementation class, not the implementation details.
Third, interface syntax
public interface myinterface{
public void Foo () {
Other methods
}
Using interfaces: Writing interfaces, implementing interfaces, using interfaces
Four, interface characteristics
1. Interfaces may not be instantiated
2. The implementation class must implement all the methods of the interface
3. Implementation classes can implement multiple interfaces
4. Variables in the interface are constants
Using Java to implement object-oriented fourth chapter