annotation in Java

Annotations are used to provide supplemental information about a program. 
* Annotations start with ‘@’.
* Annotations do not change the action of a compiled program.
* Annotations help to associate metadata to the program elements i.e. instance variables, constructors, methods, classes, etc.
* Annotations are not pure comments as they can change the way a program is treated by the compiler. 
* Annotations basically are used to provide additional information, so could be an alternative to XML and Java marker interfaces.

Annotations:
* \@Deprecated: This annotation indicates that the marked element is deprecated and should no longer be used. The compiler generates a warning whenever a program uses a method, class, or field with the @Deprecated annotation. When an element is deprecated, it should also be documented using the Javadoc @deprecated tag. The use of the at sign (@) in both Javadoc comments and in annotations is not coincidental: they are related conceptually. Also, note that the Javadoc tag starts with a lowercase d and the annotation starts with an uppercase D.
```
    /**
     * @deprecated
     * why it was deprecated
     */
    @Deprecated
    void deprecatedMethod() { }
}
```
* \@Override: This annotation informs the compiler that the element is meant to override an element declared in a superclass.
```
   @Override 
   int overriddenMethod() { }
```
* \@SuppressWarnings: This annotation tells the compiler to suppress specific warnings that it would otherwise generate. 
```
   @SuppressWarnings("deprecation")
    void useDeprecatedMethod() {
        // deprecation warning suppressed
        objectOne.deprecatedMethod();
    }
```
Every compiler warning belongs to a category. The Java Language Specification lists two categories: deprecation and unchecked. The unchecked warning can occur when interfacing with legacy code written before the advent of generics. To suppress multiple categories of warnings, use the following syntax:
```
 @SuppressWarnings({"unchecked", "deprecation"})
```
* \@SafeVarargs: This annotation, when applied to a method or constructor, asserts that the code does not perform potentially unsafe operations on its varargs parameter. When this annotation type is used, unchecked warnings relating to varargs usage are suppressed.
* \@FunctionalInterface: This annotation, introduced in Java SE 8, indicates that the type declaration is intended to be a functional interface, as defined by the Java Language Specification.
* \@Repeatable: There are some situations where you want to apply the same annotation to a declaration or type use. As of the Java SE 8 release, repeating annotations enable you to do this. 
```
@Schedule(dayOfMonth="last")
@Schedule(dayOfWeek="Fri", hour="23")
public void doPeriodicCleanup() { ... }
```