package 注解;
import java.lang.annotation.*;
public class 元注解 {
public static void main(String[] args) {
}
@MyAnnotation
public void test(){
}
}
//定义一个注解
//@Target 表示我们的注解可以用在哪些地方
@Target(value = {ElementType.METHOD})
//@Retention 表示我们的注解在什么注解在什么地方有效
//runtime>class>sources
@Retention(value = RetentionPolicy.RUNTIME)
//@Documented表示是否将我们的注解生成在javadoc中
@Documented
//@Inherited子类可以继承父类的注解
@Inherited
@interface MyAnnotation{
}
javaSE注解和反射之元注解
最新推荐文章于 2023-04-18 21:22:57 发布