Java Learning-----Interface

Source: Internet
Author: User

Through a day of learning, do a simple summary of the interface.

interface, the interface mentioned here is actually a specification and can be understood as a guideline, a basic requirement. First, an interface is a special kind of abstract class that contains only basic attribute parameters, abstract methods, inner classes, and enumeration classes. Does not include a specific implementation process. It requires other classes that want to use the interface, and describes the methods within the interface in terms of their actual situation.

In the interface, the defined property parameters are default to public static final type, the method defaults to the public abstract type, and the inner class and enum class default to the public static type.

At the same time, the use of the interface has the following basic requirements:

1. The class implements the interface through implements, and the class is an abstract type.

2. The attribute values defined in the interface cannot be modified.

3, the interface can inherit the interface.

4, a class can inherit a class at the same time, implement multiple interfaces, but extends must be in front.

5, can not be new interface object, but you can define an interface reference type of variable, and point it to the implementation of the interface object, to achieve polymorphic purposes.


The above is a brief introduction of the interface, then the interface-oriented programming is summarized.

Java Learning-----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.