zoukankan      html  css  js  c++  java
  • annotation

    一、什么是annotation

    java.lang.annotation,接口 Annotation。对于Annotation,是Java5的新特性,JDK5引入了Metadata(元数据)很容易的就能够调用Annotations。Annotations提供一些本来不属于程序的数据,比如:一段代码的作者或者告诉禁止一编译器些特殊的错误。An annotation 对代码的执行没有什么影响。Annotations使用@annotation的形式应用于代码:类(class),属性(attribute),方法(method)等等。一个Annotation出现在上面提到的开始位置,而且一般只有一行,也可以包含有任意的参数

    二、已实现类

    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出现在上面提到的开始位置,而且一般只有一行,也可以包含有任意的参数。
  • 相关阅读:
    Bookshop(一)数据库连接
    JSTL标签库(一)核心标签库
    JavaScript基础(一)之语法、变量、数据类型
    JSP页面元素构成
    微信开发(三)消息的自动回复和关注后自动回复
    微信开发(二)开发者模式接口接入
    微信开发(一)内网映射之natapp的使用
    JavaWeb监听器的使用(一)监听上下文和会话信息
    记录一下这次web实训的两个网站
    原生JS实现简易轮播图
  • 原文地址:https://www.cnblogs.com/everest7/p/10548202.html
Copyright © 2011-2022 走看看