) Interface understanding

Source: Internet
Author: User
I read the basics of Java. I have read different books and have some knowledge about Java.
I feel confused about interfaces.
Interfaces also know the specifications for using interfaces written in books, as well as interfaces used for multithreading, interface serialization, and interface listening.
But still confused, write your own program, such as some practical programs, do not know when the interface must be used ~!
I am confused about how to use the interface myself. It is estimated that it is related to beginners who are not too skilled or too knowledgeable. I only know how to use interfaces for listening program code in books.
Therefore, I would like to ask you to give an example of the interface to explain why the interface must be used. Or give me some in-depth and detailed articles on the interface.
Thank you.

Reply

The interface only defines what should be done, but does not define how to do it.
Therefore, if your program is completed by only you, and each function has only one implementation method, I think you can, note that yes, no interface
If many people work together, you may develop quickly. Unfortunately, a class you need is not completed yet. What do you do? Wait for him?
If it is interface-oriented, You can first write the simplest implementation to debug your code. Spring is a good helper.
If a function has multiple implementations, such as exporting documents. Some require HTML, some include Word, Excel, PPT, and PDF.
Because you cannot predict what they actually need. At this time, you can use interfaces to require each implementation to complete the export method.
Then, you made an Excel file and completed other items as needed. At this time, your original program does not need to be modified because they call interfaces, instead of a specific implementation 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.