Annotations are useful to provide meta data about java constructs such as class, interface,
enumerations, constructors, fields, methods, method parameters, local variables and packages.
Annotations can provide meta data about other Annotations too.
Annotations by themselves wont mean anything. So we need an Annotations processor
to perform some tasks using this meta data. The meaning and use of this meta data
is application specific.
Java provides three pre-defined annotations.
This annotation is applicable only to methods. It tells the java compiler that
the current method is overridden method of parent class or interface.
If by any chance the method signature changes in the parent class
compiler throws an error.
It tells that the annotated method or any other construct is deprecated
and may not be supported in future. Java compiler shows a warning
message when such construct is referenced.
Java compiler shows a warning message when a deprecated method is called,
a raw Collection is referenced or implemented Serializable interface
without explicitly specifying serialVersionUID.
To suppress these warnings we can annotate the construct with SuppressWarnings annotation.
Annotation definition is similar to an Interface in that it uses @interface
instead of just interface. We can define any number of attributes in
Annotation with attribute name as method name. The value would be provided
by the client using annotation.
The permitted types for annotation attributes are listed below,
All Primitive types
A simple annotation with two String attributes is shown below,