Java-元注解
// 測(cè)試 元注解
public class Test02 {@MyAnnotationpublic void test(){}
}
// 定義一個(gè)注解
// Target 表示注解可以用在哪些地方 ElementType.METHOD 是方法 ElementType.TYPE是類
@Target(value = {ElementType.METHOD, ElementType.TYPE})// Retention 表示注解在什么地方有效
// runtime > class> sources
@Retention(value = RetentionPolicy.RUNTIME)// Documented 表示是否將我們的注解生成在JAVAdoc中
@Documented// Inherited 子類可以繼承父類的注解
@Inherited
@interface MyAnnotation{
}
https://www.bilibili.com/video/BV1p4411P7V3?p=3&spm_id_from=pageDriver
總結(jié)
- 上一篇: JavaScript 常用工具函数
- 下一篇: java的整数扩展,浮点数扩展,字符扩展