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是什么意思
发布评论