The concept of interface
##Interface reflects the scalability of things. To give a specific example, we know that cats cannot jump high, but when the Cat class implements the Jumping interface, the cat can jump high. In other words, the thing "cat" expands the function of "high jump".
Use of interface
Define an interface class-Jumping The implementation class Cat implements the Jumping interface Test class.
Look at the left side for compilation and the right side for execution, so the execution result is:
Interface and class
1. Between classes Classes and classes can be connected through inheritance (extends), but inheritance can only be single inheritance. 2. Interfaces and interfaces Interfaces and interfaces can also be connected through inheritance (extends), but inheritance in interfaces can be multiple inheritance. 3. Between classes and interfacesThe connection between classes and interfaces can be through implementations, or there can be multiple implementations, just separate them with commas. Note: It is worth mentioning that if a subclass wants to inherit the parent class and implement the interface, it is also possible. The usage format is:public class Cat extends Animal implements Jumpping,Dancin
The above is the detailed content of [java object-oriented] Describe the interface in detail. For more information, please follow other related articles on the PHP Chinese website!