Functions and benefits of java Interfaces
1. Functions of java Interfaces
Http://blog.csdn.net/hack_bug/article/details/7634737
2. A Java expert's answer
Many JAVA beginners are confused about the meaning of interfaces. I don't know what the interface does or why it should be defined.
It seems that the interface definition is redundant in advance. Below I will give you a summary of the four meanings of interfaces in JAVA:
1. Importance: abstract class and interface support the definition of abstract classes in Java. The existence of these two mechanisms gives Java powerful object-oriented capabilities.
2. Simple and normative: if a project is relatively large, an architect who can clarify all business needs to define some major interfaces, these interfaces not only tell developers that you need to implement those businesses, but also restrict naming rules (to prevent some developers from being able to understand them by naming them casually ).
3. Maintenance and scalability: for example, if you want to create an artboard program, there is a panel class in it, mainly responsible for the painting function, and then you define this class.
But in the near future, you will suddenly find that this class cannot satisfy you, and then you will re-design this class. Even worse, you may have to give up this class, it may be difficult to modify it because it may be referenced elsewhere.
If you define an interface, place the rendering function in the interface, and then implement the interface when defining the class, then you only need to reference the class to implement it using this interface, if you want to change it in the future, you just need to reference another class to facilitate maintenance and expansion.
4. Security and rigor: interfaces are an important means for software loose coupling. They describe all external services of the system without any specific implementation details. In this way, it is safer and more rigorous (generally, software service providers consider more ).
3. What is the purpose of defining interfaces in a class?
Http://www.dewen.net.cn/q/172.16/java:can I define an interface in a class?