Home  >  Article  >  Java  >  What is the interface

What is the interface

王林
王林Original
2020-06-28 15:52:237498browse

An interface is a series of method declarations and a collection of method characteristics. An interface only has method characteristics but no method implementation. Therefore, these methods can be implemented by different classes in different places, and these implementations can Have different behaviors (functions).

What is the interface

java interface

(Recommended learning: java entry program)

Java interface is a The declaration of a series of methods is a collection of method characteristics. An interface only has method characteristics but no method implementation. Therefore, these methods can be implemented by different classes in different places, and these implementations can have different behaviors (functions).

Two meanings: first, Java interface, a structure that exists in the Java language, has specific syntax and structure; second, a set of characteristics of methods possessed by a class, which is a logical abstraction. The former is called "Java interface" and the latter is called "interface".

(Video tutorial recommendation: java video tutorial)

Define the format of the interface

[public]interface 接口名称 [extends父接口名列表]
{
//静态常量
[public] [static] [final] 数据类型变量名=常量值;
//抽象方法
[public] [abstract] [native] 返回值类型方法名(参数列表);
}

Implement the format of the interface

[修饰符] class 类名[extends 父类名] [implements 接口A,接口B,···]
{
类成员变量和成员方法;
为接口A中的所有方法编写方法体,实现接口A;
为接口B中的所有方法编写方法体,实现接口B;
}

The above is the detailed content of What is the interface. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn