Use of interfaces
Interface (Interface): in essence, an interface is a special kind of abstract class
Special points
Definition of the interface
1. All methods should be public ( and abstract )
2 . all the attributes should be publicstatic Final Static Constants
3. Span lang= "ZH-CN" style= "Font-family:simsun" > interfaces can inherit < span> use Extends ( allow multiple inheritance , multiple between , interval )
4. There can be no construction method in the interface , cannot use new, no main method
Implementation of the interface
Key Words : Implements
1. The implementation of the interface must be done through the class
2. To implement an interface class , Be sure to complete the abstract method in the interface , Otherwise the implementation class is an abstract class ( abstract classes can inherit interfaces )
3. the implementation class of the interface can implement several interfaces at the same time ( to solve multiple inheritance methods )
The role of the interface
1. Indirect implementation of multiple inheritance
2. Specification of the implementation of the class ( method definition )
3. Program decoupling design : separating the standards used and the implementation criteria to achieve portability of code design ---AOP
Back to Java Memoirs (v): Use of the Java05 interface