首页 > IT职业 > IT职场 > java中@Inherited是什么?

说明
1、标记表明某个标记的类型被继承,@inherited修饰的annotation类型被用于class,annotation被用于class的子类,@inheritedannotation类型被标记的class的子类。
作用
2、允许子类继承父类注释。
实例
MyParentClass在用的注释标记是@Inherited,子类可以继承注释信息。
java.lang.annotation.Inherited
@Inherited
public @interface MyCustomAnnotation {
}
@MyCustomAnnotation
public class MyParentClass {
...
}
public class MyChildClass extends MyParentClass {
...
}
以上就是java中@Inherited的介绍,希望对大家有所帮助。更多Java学习指路:Java基础
本教程操作环境:windows7系统、java10版,DELL G3电脑。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4692/viewspace-2830011/ ,如需转载,请注明出处,否则将追究法律责任。