I have read several interface content on the Internet, including popular and professional content. Based on these content and my own understanding, I will write down the following experiences. If you have any questions or errors, please do not give me any further advice.
The interface is declared using the interface. The naming principle starts with I. For example, to define a socket isocket, define two ports and three ports and two jacks in the isocket. This should also be noted that both members are public, if other Members must be public, this interface is basically complete. In fact, the interface is a standard for implementing classes.
Then write the specific implementation class and write a method for the two-port jack standard. If the voltage is set to 50 V, we can use this interface to instantiate this class, to achieve the goal of inserting a 50 V two-port socket. If you want to insert a V three-port jack, you can add such a method in this class, or create a new class to add such a method.
It can be said that interfaces are a standard for communication between different classes and are provided to the same rules for different classes. The printer examples on the Internet are also very understandable.