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出现在上面提到的开始位置,而且一般只有一行,也可以包含有任意的参数。
  • 相关阅读:
    Ubuntu 14.04 设置静态IP
    Spring MVC 入门就这一篇
    一站式轻量级框架 Spring
    深入 Web 请求过程
    使用 Docker Compose 搭建 Nexus 依赖私服及使用配置
    Spring Cloud Alibaba 与 Dubbo 的完美融合
    使用 Spring Cloud Alibaba Nacos Config 作为配置中心
    使用 Spring Cloud Alibaba Nacos 实现服务注册与发现
    Spring Boot 监听 Redis Key 失效事件实现定时任务
    使用 Spring Boot Admin 监控服务
  • 原文地址:https://www.cnblogs.com/everest7/p/10548202.html
Copyright © 2011-2022 走看看