Back to Java Memoirs (v): Use of the Java05 interface

Source: Internet
Author: User


Use of interfaces

Interface (Interface): in essence, an interface is a special kind of abstract class

Special points

Definition of the interface

1. All methods should be public ( and abstract )

2 . all the attributes should be publicstatic Final Static Constants

3. Span lang= "ZH-CN" style= "Font-family:simsun" > interfaces can inherit < span> use Extends ( allow multiple inheritance , multiple between , interval )

4. There can be no construction method in the interface , cannot use new, no main method

Implementation of the interface

Key Words : Implements

1. The implementation of the interface must be done through the class

2. To implement an interface class , Be sure to complete the abstract method in the interface , Otherwise the implementation class is an abstract class ( abstract classes can inherit interfaces )

3. the implementation class of the interface can implement several interfaces at the same time ( to solve multiple inheritance methods )

The role of the interface

1. Indirect implementation of multiple inheritance

2. Specification of the implementation of the class ( method definition )

3. Program decoupling design : separating the standards used and the implementation criteria to achieve portability of code design ---AOP

Back to Java Memoirs (v): Use of the Java05 interface

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.