【Java】-NO.17.EBook.4.Java.1.014-【疯狂Java讲义第3版 李刚】- Annotation
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 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 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的更多相关文章
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
- 【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 ...
随机推荐
- onems设备管理系统(TR-069和OMA)
onems设备管理系统(TR-069和OMA) 沃克斯科技OneMS设备管理套件是一个全面的为服务提供商和企业提供自动配置和远程管理功能的设备管理解决方案.它利用现有的网络基础设施来自动化订购,预配置 ...
- Centos 解决SSH 免密码登录 以及Crontab制作定时SSH自动登录和关闭的脚本
一.SSH免密码登录 假设要登录的机器为192.168.1.100,当前登录的机器为192.168.1.101. 首先在101的机器上生成密钥(如果已经生成可以跳过): $ ssh-keygen -t ...
- SQL逻辑查询语句执行顺序 需要重新整理
一.SQL语句定义顺序 1 2 3 4 5 6 7 8 9 10 SELECT DISTINCT <select_list> FROM <left_table> <joi ...
- 10.20stark组件已经完工
2018-10-20 19:37:31 stark组件已经做完!基本上和Django的admin一样! 放上github连接:https://github.com/TrueNewBee/pythonD ...
- 【Java并发编程六】线程池
一.概述 在执行并发任务时,我们可以把任务传递给一个线程池,来替代为每个并发执行的任务都启动一个新的线程,只要池里有空闲的线程,任务就会分配一个线程执行.在线程池的内部,任务被插入一个阻塞队列(Blo ...
- Linux多进程和多线程的一次gdb调试实例
转载https://typecodes.com/cseries/multilprocessthreadgdb.html 1 原文整理 默认设置下,在调试多进程程序时gdb只会调试主进程.gdb7以上的 ...
- Ajax请求参数较长导致请求失败
Ajax请求参数比较长,第5行参数大概1100个字符吧,是接口的请求报文. $.ajax({ type:"POST", url:"${ctx}/test.action?m ...
- tomcat启动项目报错:The specified JRE installation does not exist
在Build Path里设置好jre和各Library的顺序,代码无报错,启动时弹框,里面的信息是:The specified JRE installation does not exist. 后来想 ...
- leetcode第三题
leetcode第三题: 题目: 给定一个字符串,找出不含有重复字符的最长子串的长度. 源码(使用java语言): class Solution { public int lengthOfLonges ...
- [No0000128]SQL纵表与横表互转
1.纵表转横表: 纵表结构:Table1 转换后的横表结构: Sql示例代码: select username, sum(case Course when '语文' then Grade else 0 ...