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注解和反射之元注解
猜你喜欢
转载自blog.csdn.net/qq_42794826/article/details/109033104
今日推荐
周排行