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

元注解

作者:互联网

元注解

 

package com.hua.annotation;

import java.lang.annotation.*;

//测试元注解
@MyAnnotation
public class Test02 {

    @MyAnnotation
    public void test(){

    }
}

//定义一个注解
//Target 表示我们的注解可以用在哪些地方
@Target(value ={ElementType.METHOD,ElementType.TYPE})

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

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

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

}

 

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