1.0.0 Summary

Tittle:【Java】-NO.17.EBook.4.Java.1.014-【疯狂Java讲义第3版 李刚】-  Annotation

Style:EBook

Series:Java

Since:2017-11-01

End:....

Total Hours:...

Degree Of Diffculty:2

Degree Of Mastery:2

Practical Level:2

Desired Goal:2

Archieve Goal:....

Gerneral Evaluation:...

Writer:kingdelee

Related Links:

http://www.cnblogs.com/kingdelee/

1.java.lang 的 5个Annotation

api :https://docs.oracle.com/javase/9/docs/api/java/lang/package-summary.html

Annotation Types Summary
Annotation Type Description
Deprecated
A program element annotated @Deprecated is one that programmers are discouraged from using.
FunctionalInterface
An informative annotation type used to indicate that an interface type declaration is intended to be a functional interface as defined by the Java Language Specification.
Override
Indicates that a method declaration is intended to override a method declaration in a supertype.
SafeVarargs
A programmer assertion that the body of the annotated method or constructor does not perform potentially unsafe operations on its varargs parameter.
SuppressWarnings
Indicates that the named compiler warnings should be suppressed in the annotated element (and in all program elements contained in the annotated element).

2.java.lang.annotation 的 6个meta Annotation

https://docs.oracle.com/javase/9/docs/api/java/lang/annotation/package-summary.html

Annotation Types Summary
Annotation Type Description
Documented
If the annotation @Documented is present on the declaration of an annotation type A, then any @A annotation on an element is considered part of the element's public contract.
Inherited
Indicates that an annotation type is automatically inherited.
Native
Indicates that a field defining a constant value may be referenced from native code.
Repeatable
The annotation type java.lang.annotation.Repeatable is used to indicate that the annotation type whose declaration it (meta-)annotates is repeatable.
Retention
Indicates how long annotations with the annotated type are to be retained.
Target
Indicates the contexts in which an annotation type is applicable.

2.1 @Retention

当需要使用的注解考虑在运行时可以被程序反射读取,则在该注解上加

@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation{}

  

2.2 @Target

用于指定注解修饰的作用域

// 我定义的注解只能修饰成员变量
@Target(ElementType.FIELD)
public @interface MyAnnotation{}

  

2.3 @Document

指定可以被提取出文档,一般需要出现在文档的都是必写。

2.4 @Inherited

类B继承类A,类A使用@Inherited时,类B同样继承了类A的@Inherited特性

2.5 @Repeatable

3. 反射获取注解信息

【Java】-NO.17.EBook.4.Java.1.014-【疯狂Java讲义第3版 李刚】- Annotation的更多相关文章

  1. 【Java】-NO.16.EBook.4.Java.1.007-【疯狂Java讲义第3版 李刚】- Java基础类

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.007-[疯狂Java讲义第3版 李刚]-  Java基础类 Style:EBook Series:J ...

  2. 【Java】-NO.16.EBook.4.Java.1.008-【疯狂Java讲义第3版 李刚】- 集合/容器

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.008-[疯狂Java讲义第3版 李刚]- 集合 Style:EBook Series:Java Si ...

  3. 【Java】-NO.16.EBook.4.Java.1.011-【疯狂Java讲义第3版 李刚】- AWT

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.011-[疯狂Java讲义第3版 李刚]-  AWT Style:EBook Series:Java ...

  4. 【Java】-NO.16.EBook.4.Java.1.012-【疯狂Java讲义第3版 李刚】- Swing

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.011-[疯狂Java讲义第3版 李刚]-  Swing Style:EBook Series:Jav ...

  5. 【Java】-NO.16.EBook.4.Java.1.012-【疯狂Java讲义第3版 李刚】- JDBC

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.012-[疯狂Java讲义第3版 李刚]-  JDBC Style:EBook Series:Java ...

  6. 【Java】-NO.16.EBook.4.Java.1.005-【疯狂Java讲义第3版 李刚】- 枚举

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.005-[疯狂Java讲义第3版 李刚]- 枚举 Style:EBook Series:Java Si ...

  7. 【Java】-NO.16.EBook.4.Java.1.006-【疯狂Java讲义第3版 李刚】- 垃圾回收

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.006-[疯狂Java讲义第3版 李刚]- 垃圾回收 Style:EBook Series:Java ...

  8. 【Java】-NO.16.EBook.4.Java.1.009-【疯狂Java讲义第3版 李刚】- 泛型

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.009-[疯狂Java讲义第3版 李刚]- 泛型 Style:EBook Series:Java Si ...

  9. 【Java】-NO.16.EBook.4.Java.1.010-【疯狂Java讲义第3版 李刚】- 异常

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.010-[疯狂Java讲义第3版 李刚]- 异常 Style:EBook Series:Java Si ...

随机推荐

  1. python 读取配置文件方法

    #coding=utf8 import ConfigParser config = ConfigParser.ConfigParser() config.readfp(open(raw_input(& ...

  2. Spark RDD Action 简单用例(二)

    foreach(f: T => Unit) 对RDD的所有元素应用f函数进行处理,f无返回值./** * Applies a function f to all elements of this ...

  3. 微信生成二维码 只需一个网址即刻 还有jquery生成二维码

    <div class="orderDetails-info"> <img src="http://qr.topscan.com/api.php?text ...

  4. lombok安装方法

    一.介绍 lombok网址:https://projectlombok.org/download.html lombok能够在编译源码的时候自动生成getter和setter方法.即它最终能够达到的效 ...

  5. POJ 2027 - No Brainer

    Description Zombies love to eat brains. Yum. Input The first line contains a single integer n indica ...

  6. python中OrderedDict的使用

    很多人认为python中的字典是无序的,因为它是按照hash来存储的,但是python中有个模块collections(英文,收集.集合),里面自带了一个子类 OrderedDict,实现了对字典对象 ...

  7. vue中导入外面文件(css,js)方式

    有时我们需要导入外面的css文件(例如reset.css文件,bootstrap.css,jQuery.js文件),通常可通过import "name.css"的形式 对于rese ...

  8. opencv -python

    https://www.python----------tab.com/html/2017/pythonhexinbiancheng_1120/1184.html http://www.cnblogs ...

  9. hdfs mapreduce hbase

    参考资料:http://www.cnblogs.com/sharpxiajun/p/5585613.html 大数据时代的数据量是超大规模的,传统的关系数据库已经很难存储和管理这些数据了,为了存储海量 ...

  10. 《HTTP - 基于http的认证》

    推荐一首歌 - 好吧,今天刚入职第二天,也没听歌. 哈哈哈哈. 1:何为认证? - 其实这个问题就比较宽泛了,总的来说,就是你有证明你身份的标识. - 和人类社会一样,你花了钱想看一场场演唱会,但是谁 ...