Java注解学习总结
元数据,
jdk5.0引入,
类、方法、变量、参数、包可以被标注,
可以通过反射获取注解内容,
内置注解:
@Override @Deprecated@SuppressWarnings
负责创建注解的元注解:
@Target(目的)、@Retention(保留)、@Documented(被Javadoc包含)、@Inherited(允许子类继承父类注解)
创建注解:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface AnnotationTest{}
借用反射机制读取注解 getAnnotation()方法。