201671010145 2016-2017 Java programming Java interface features

Source: Internet
Author: User
Tags comparable
In the Java language Specification, a method's characteristics include only the name of the method, the number and kind of parameters, not the return type of the method, the name of the parameter, and the exception that was thrown. When the Java compiler examines the overloads of a method, it determines whether two methods are overloaded by these conditions. However, when the Java compiler examines the substitution of a method, it further checks whether the return type of the two methods (sub-type and subtype) is the same as the thrown exception. Interface implementation and class inheritance rules, in order to secure the data, the inheritance of a class only a direct parent class, that is, single inheritance, but a class can implement multiple interfaces, the interface to compensate for the class cannot inherit the disadvantage, inheritance and interface of the dual design both maintain the class of data security also disguised implementation of multiple inheritance. The Java interface itself has no implementation, because the Java interface does not involve appearances, but only describes the public behavior, so the Java interface is more abstract than the Java abstract class. But the interface is not a class, and you cannot instantiate an interface with the new operator. such as x=new comparable (... );//This is a mistake. However, the interface variable comparable x can be declared; This is permissible. Java interface methods can only be abstract and public, Java interfaces cannot have constructors, Java interfaces can have public, static, and final properties. That is, the properties in the interface can be defined as public static final int value=5, and the interface separates the characteristics of the method from the implementation of the method. This segmentation is reflected in the interface, which often represents a role that wraps the actions and attributes associated with the role, and the class that implements the interface is the actor who plays the role. A character is played by different actors, and different actors, apart from playing a common role, do not ask for anything in common.

201671010145 2016-2017 Java programming Java interface features

Related Article

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.