How to use of Annotations in Java

In J2SE 5.0, The annotations are also known as metadata. It is used to merge additional Java elements with the programming elements, such as classes, methods, parameters, local variables, packages, and fields. Metadata is stored in Java class files by the compiler and these class files are used by the JVM.

Annotation Description
@DeprecatedThe compiler warns when deprecated java elements are used in the non-deprecated program.
@OverridesCompiler generated error when the method uses this annotation type doesn't override the methods present in the superclass.

Importance of Annotations:

1. Do not use extends clause. It automatically extends the marker interface java.lang.annotation Annotation.

2. Don’t use my parameter for a method.

3. Do not use generic methods.

4. Don’t use the throws clause.