9.6. Annotation Types

An annotation type declaration is a special kind of interface declaration. To distinguish an annotation type declaration from an ordinary interface declaration, the keyword interface is preceded by an at-sign (@).

Note that the at-sign (@) and the keyword interface are two distinct tokens. Technically it is possible to separate them with whitespace, but this is discouraged as a matter of style.

AnnotationTypeDeclaration:    InterfaceModifiersopt @ interface Identifier AnnotationTypeBodyAnnotationTypeBody:    { AnnotationTypeElementDeclarationsopt }AnnotationTypeElementDeclarations:    AnnotationTypeElementDeclaration    AnnotationTypeElementDeclarations AnnotationTypeElementDeclaration

If an annotation a9.7) on an annotation ...

Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.