Java annotations are a method of associating metadata with program elements, enabling the extraction of program behaviors from annotations and the generation of interdependent code by the Java compiler or VM. This type of annotation-based development has been available since Java SKD 5.0.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Within the Java development kit (JDK), there are simple annotations used to make comments on code, as well as meta-annotations that can be used to create annotations within annotation-type declarations. While simple annotations can be used to make comments on code and its use, meta-annotations can describe how an annotation itself may be used and where.
Annotation type definitions are noted by the at sign (@), followed by an interface and the annotation name. Annotations themselves are shown as @ along with the annotation type. At compile time, annotation processor plug-ins can process the code within annotations to extract behaviors that create extra messages, source files and other resources, all of which then themselves may be compiled and processed.
The Java compiler itself reserves a special set of annotations for syntax-related purposes, including @Deprecated, @Override and @SurpressWarnings.