java中interface是什么意思

编程入门 行业动态 更新时间:2024-10-18 07:46:54

<a href=https://www.elefans.com/category/jswz/34/1770091.html style=java中interface是什么意思"/>

java中interface是什么意思

mavis..

102

接口:

通常,接口公开合同而不暴露底层实现细节.在面向对象编程中,接口定义了暴露行为但不包含逻辑的抽象类型.实现由实现接口的类或类型定义.

@interface :(注释类型)

以下面的例子,其中有很多评论:

public class Generation3List extends Generation2List {

// Author: John Doe

// Date: 3/17/2002

// Current revision: 6

// Last modified: 4/12/2004

// By: Jane Doe

// Reviewers: Alice, Bill, Cindy

// class code goes here

}

您可以声明注释类型,而不是这样

@interface ClassPreamble {

String author();

String date();

int currentRevision() default 1;

String lastModified() default "N/A";

String lastModifiedBy() default "N/A";

// Note use of array

String[] reviewers();

}

然后可以按如下方式对类进行注释:

@ClassPreamble (

author = "John Doe",

date = "3/17/2002",

currentRevision = 6,

lastModified = "4/12/2004",

lastModifiedBy = "Jane Doe",

// Note array notation

reviewers = {"Alice", "Bob", "Cindy"}

)

public class Generation3List extends Generation2List {

// class code goes here

}

PS:

许多注释取代了代码中的注释.

很好的解释 (9认同)

这实际上很有用.我不知道Java可以做到这一点. (2认同)

更多推荐

java中interface是什么意思

本文发布于:2024-02-06 12:30:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749143.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:java   interface

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!