Most visited

Recently visited

Added in API level 1

Target

public abstract @interface Target
implements Annotation

java.lang.annotation.Target


指示注释类型适用的程序元素的种类。 如果注释类型声明中不存在目标元注释,则可以在任何程序元素上使用声明的类型。 如果存在这样的元注释,编译器将执行指定的使用限制。 例如,这个元注释表明声明的类型本身就是一个元注释类型。 它只能用于注释类型声明:

    @Target(ElementType.ANNOTATION_TYPE)
    public @interface MetaAnnotationType {
        ...
    }
 
This meta-annotation indicates that the declared type is intended solely for use as a member type in complex annotation type declarations. It cannot be used to annotate anything directly:
    @Target({})
    public @interface MemberType {
        ...
    }
 
It is a compile-time error for a single ElementType constant to appear more than once in a Target annotation. For example, the following meta-annotation is illegal:
    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD})
    public @interface Bogus {
        ...
    }
 

Summary

Inherited methods

From interface java.lang.annotation.Annotation

Hooray!