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. maven安装与创建多模块项目

    最新版已同步至 http://yywang.info/2014/05/31/maven-install-and-create-project/ maven是一个比较流行的项目管理工具,在最近参与的项目 ...

  2. 洛谷P1182 数列分段【二分】【贪心】

    题目:https://www.luogu.org/problemnew/show/P1182 题意: 有n个数,要分成连续的m段.将每段中的数相加,问之和的最大值的最小值是多少. 思路: 和P1316 ...

  3. 网龙“MAD技术论坛”在榕举办 200余位技术人才共话“改变教育”

    9月16日,由网龙网络公司主办.msup协办的“MAD技术论坛”在榕举办,来自美国.香港.苏州等地的技术大牛受邀来到福州,围绕“Make a difference to education”这一论坛主 ...

  4. 体验 ASP.NET Core 集成测试三剑客:xUnit.net、TestServer、EF Core InMemory

    这是昨天解决的一个问题,针对一个 web api 的客户端代理类写集成测试,既要测试 web api,又要测试 web api 客户端. 测试 web api,就要在运行测试时自动启动 web api ...

  5. 将GitLab数据库从阿里云PostgreSQL RDS迁移至自建的PostgreSQL服务器

    阿里云RDS目前支持的是PostgreSQL 9.4,而gitlab支持的最低版本是PostgreSQL 9.6.1,不升级PostgreSQL,gitlab就无法升级,阿里云RDS短期内不进行升级, ...

  6. CH #46A - 磁力块 - [分块]

    题目链接:传送门 描述在一片广袤无垠的原野上,散落着N块磁石.每个磁石的性质可以用一个五元组(x,y,m,p,r)描述,其中x,y表示其坐标,m是磁石的质量,p是磁力,r是吸引半径.若磁石A与磁石B的 ...

  7. python字符串常用方法

    #1.strip()去掉空格(字符串首.尾空格).lstrip()去掉左侧空格.rstrip()去掉右侧空格print(' abc '.lstrip())#>>abcprint(' abc ...

  8. ios开发之 NSObject详解

    NSObject是大部分Objective-C类继承体系的根类.这个类遵循NSObject协议,提供了一些通用的方法,对象通过继承NSObject,可以从其中继承访问运行时的接口,并让对象具备Obje ...

  9. Flink – submitJob

    Jobmanager的submitJob逻辑, /** * Submits a job to the job manager. The job is registered at the library ...

  10. <大话设计模式>工厂模式,策略模式

    第一章:工厂模式: 通过封装,继承,多态解耦合 业务逻辑和界面逻辑分开 用单独的类创造实例,工厂:创造实例 工厂模式还可以用反射来实现,nsstringFromClass UML类图 聚合表示一众弱的 ...