Java interface definition (translated from Java tutorials)

Source: Internet
Author: User

From http://www.cnblogs.com/ggjucheng/archive/2012/12/04/2802120.html

English from http://docs.oracle.com/javase/tutorial/java/IandI/interfaceDef.html

An interface declaration consists of a modifier, a keyword interface, an interface name, a list of parent interfaces separated by commas (,) (if any), and an interface body. For example:

Public InterfaceGroupedinterfaceExtendsInterface1, interface2, interface3 {//Constant declarations//Base of natural logarithmsDoubleE = 2.718282;//Method signaturesVoidDosomething (IntI,DoubleX );IntDosomethingelse (string S );}

 

Public access indicates that the interface can be used by any package class. If you do not specify the public interface, your interface can only be accessed by the class of the same package.

An interface can inherit other interfaces, just like a class can inherit other classes. However, a class can inherit only one other class, and an interface can inherit any number of interfaces. The interface declaration contains all interfaces to be inherited by commas (,).

 

Interface body

The API provides a declaration that contains all methods. A method declaration of the interface is followed by a semicolon, but there is no braces, because the interface does not provide implementation for the method. All method declarations are implicitly public, so the public modifier can be ignored.

An interface can contain a constant declaration. The constant Declaration of the interface, which is implicitly public, static, final. Again, these modifiers can be ignored.

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.