其他分享
首页 > 其他分享> > 元注解

元注解

作者:互联网

package com.wang.annotation;


import java.lang.annotation.*;

//定义一个注解
//Target 表示我们的注解可以用在哪些地方
//测试元注解
@MyAnnotation
public class Test02 {
    public void test(){
        
    }
}
@Target(value = {ElementType.METHOD,ElementType.TYPE})

//Retention 表示我们的注解在什么地方还有效
//runtime>class>sources
@Retention(value= RetentionPolicy.RUNTIME)

//Documented 表示是否将我们的注解生成在JAVAdoc中
@Documented

//Inherited 子类可以继承父类的注解
@Inherited
@interface MyAnnotation{


}

标签:Target,Inherited,注解,Documented,annotation,Retention
来源: https://www.cnblogs.com/wshjyyysys/p/15869700.html