注解和反射
1、注解 1.1、内置注解 @Override 子类重写方法 @Deprecated 标识这个方法或者类已经被废弃或有更好的选择 @SuppressWarnings 抑制编译器告警 1.2、元注解 元注解是用来修饰注解的注解 @Target 指定注释的使用范围 @Retention 注释的生命周期,有SOURCE(编译时被抛弃),CLASS(class文件中存在,但是运行时被抛弃),RUNTIME(运行时依然存在) @Documented 标识生成javadoc时,该注解修饰的注解也会在javadock中显示 @Inherited 某个类使用了用@Inherited注解标识的注解,则他的子类也会继承这个注解 1.3、自定义注解 使用@interface定义注解 import java.lang.annotation.*; @Target(value = {ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited public @interface My....