Annotations provide information about a program. Annotations are usually used to support tools such as the compiler and during the execution of the program. For example, the @Override annotation informs the compiler that a method is overriding a base class method. If the method does not actually override the base class method because it is misspelled, the compiler will generate an error.
Annotations are applied to elements of the application such as a class, method, or field. It begins with the at sign, @, is followed by the name of the annotation, and optionally a list of values enclosed in a set of parentheses.
Common compiler annotations are detailed in the following table:
@Deprecated Used by the compiler to indicate that the element should not be used
@Override The method overrides the base class method
@SuppressWarnings Used to suppress specific compiler warnings
Annotations can be added to an application and used by the third-party tools for specific purposes. It is also possible to write your own annotations when needed. Annotations are useful in conveying information about an application to tools and the run-time environment.