Functions and benefits of java Interfaces

Source: Internet
Author: User

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?

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.