Standard Annotations

JDK 5.0 defines seven annotation interfaces. Three of them are regular annotations that you can use to annotate items in your source code. The other four are meta-annotations that describe the behavior of annotation interfaces. Table 13-1 shows these annotations. We discuss them in detail in the following two sections.

Table 13-1. The Standard Annotations
Annotation InterfaceApplicable ToPurpose
DeprecatedAllMarks item as deprecated
SuppressWarningsAll but packages and annotationsSuppresses warnings of the given type
OverrideMethodsChecks that this method overrides a superclass method
TargetAnnotationsSpecifies the items to which this annotation can be applied
RetentionAnnotationsSpecifies how long this annotation is retained

Get Core Java™ 2 Volume II - Advanced Features, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.