元注解的作用就是负责注解其他注解 , Java定义了4个标准的meta-annotation类型,他们被用来提供 对其他annotation类型作说明 .这些类型和它们所支持的类在java.lang.annotation包中可以找到 .( @Target , @Retention , @Documented , @Inherited )
@Target : 用于描述注解的使用范围(即:被描述的注解可以用在什么地方)@Retention : 表示需要在什么级别保存该注释信息 , 用于描述注解的生命周期 (SOURCE < CLASS < RUNTIME)@Document:说明该注解将被包含在javadoc中@Inherited:说明子类可以继承父类中的该注解
package annotation
;
import java
.lang
.annotation
.*
;
public class test02 {
@MyAnnotation
public void test(){
}
}
@Target(value
= {ElementType
.METHOD
,ElementType
.TYPE
})
@Retention(value
= RetentionPolicy
.RUNTIME
)
@Documented
@Inherited
@
interface MyAnnotation{
}