1、用于类的继承,意思是说带有@Inherited注解的注解修饰的类的子类也自动继承这个注解
2、只有类有继承,所以继承只对应子类有效
下面是小例子。
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface InheritedTest1 {
String value();
}
@Retention(RetentionPolicy.RUNTIME)
public @interface InheritedTest2 {
String value();
}
public class Main