216.7.14 interface

Source: Internet
Author: User

Interface:

Interface is the realization of the same function in many parent classes, can be implemented more;

The public modifier in the interface is necessary, in the subclass that is, the implements interface can not be less than the decoration of the interface is the need to use public, the default is no, because its permissions are default;

An abstract method in an interface is not a principal, and it is implemented by a subclass by overriding it.

The format of the interface:

public static final Capital English name ();

public abstract void Method name ();

When to use the interface:

In addition to the common functions of the parent class, other specific functions of friends, and subclasses are not indispensable, you can define the interface and then to implement it.

Benefits of the interface:

Greatly improve the extensibility of the Code;

So that the class and class are not so coupled;

A class can implement multiple interfaces, and functions can be extended.

216.7.14 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.