ANNOTATION

Java, being a wonderful object-oriented language provided support for Annotations starting from 5.0. This feature was added to Java 5.0 as a result of the JSR 175 namely “A Metadata Facility for the JavaTM Programming Language”.
Annotations in Java can be seen elsewhere in a program. It can be seen in class declaration, method declaration, field declaration etc. The added Annotation to Java Elements have proven themselves to be considerably useful in many instances.
Annotations provide data about a program that is not part of the program itself. They have no direct effect on the operation of the code they annotate. Annotations have a number of uses, among them.
 
Information for the compiler: Annotations can be used by the compiler to detect errors or suppress warnings.
Compiler-time and deployment-time processing: Software tools can process annotation information to generate code, XML files, and so forth.
Runtime processing: Some annotations are available to be examined at runtime.Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements. The annotation appears first, often (by convention) on its own line, and may include elements with named or unnamed values.
 
1
2
3
4
5
          @Author(
   name = "BBS Technnologies",
   date = "07/08/2014"
)
class MyClass() { }
1
2
@SuppressWarnings(value = "unchecked")
void myMethod() { }

If there is just one element named "value," then the name may be omitted, as in:

1
2
@SuppressWarnings("unchecked")
void myMethod() { }

Also, if an annotation has no elements, the parentheses may be omitted, as in:

1
2
@Override
void mySuperMethod() { }

Documentation:

Many annotations replace what would otherwise have been comments in code. Suppose that a software group has traditionally begun the body of every class with comments providing important information:

1
2
3
4
5
6
7
8
9
public class Generation3List extends Generation2List {
   // Author: John Doe<br>
   // Date: 3/17/2002<br>
   // Current revision: 6<br>
   // Last modified: 4/12/2004<br>
   // By: Jane Doe<br>
   // Reviewers: Alice, Bill, Cindy<br>
   // class code goes here<br>
}