1、什么是annotationjava
java.lang.annotation,接口 Annotation。对于Annotation,是Java5的新特性,JDK5引入了Metadata(元数据)很容易的就可以调用Annotations。Annotations提供一些原本不属于程序的数据,好比:一段代码的做者或者告诉禁止一编译器些特殊的错误。An annotation 对代码的执行没有什么影响。Annotations使用@annotation的形式应用于代码:类(class),属性(attribute),方法(method)等等。一个Annotation出如今上面提到的开始位置,并且通常只有一行,也能够包含有任意的参数app
2、已实现类ide
public interface Annotation全部 annotation 类型都要扩展的公共接口。注意,手动扩展该公共接口的接口不定义 annotation 类型。还要注意此接口自己不定义 annotation 类型。
对于Annotation,是Java5的新特性,下面是Sun的Tutorial的描述,由于是英文,这里我翻译下,但愿可以比较清晰的描述一下Annotation的语法以及思想。Annotation:Release 5.0 of the JDK introduced a metadata facility called annotations. Annotations provide data about a program that is not part of the program,such as naming the author of a piece of code or instructing the compiler to suppress specific errors. An annotation has no effect on how the code performs. Annotations use the form @annotation and may be applied to a program's declarations: its classes,fields,methods,and so on. The annotation appears first and often (by convention) on its own line,and may include optional arguments: JDK5引入了Metadata(元数据)很容易的就可以调用Annotations.Annotations提供一些原本不属于程序的数据,好比:一段代码的做者或者告诉
编译器禁止一些特殊的错误。An annotation 对代码的执行没有什么影响。Annotations使用@annotation的形式应用于代码:类(class),属性(field),方法(method)等等。一个Annotation出如今上面提到的开始位置,并且通常只有一行,也能够包含有任意的参数。