A form of metadata, provide data about a program that is not part of the program itself.
Annotations
What are the uses of annotations?
Annotations basics
Annotations can also be applied to the use of types
type annotation
Indicates that the marked element is deprecated and should no longer
be used.
@Deprecated
When an element is deprecated, it should also be documented using
the Javadoc
@deprecated
Informs the compiler that the element is meant to override an element
declared in a superclass.
Not required, but avoids errors (promotes proper overriding)
@Override
Annotation tells the compiler to suppress specific warnings that it
would otherwise generate
@SuppressWarnings
annotation specifies how the marked annotation is stored
@Retention
annotation indicates that whenever the specified
annotation is used those elements should be documented using the
Javadoc tool
@Documented
annotation marks another annotation to restrict what kind of Java elements the annotation can be applied to
@Target
annotation indicates that the annotation type can be
inherited from the super class
@Inherited
annotation, indicates that the marked annotation can be applied more than once to the same declaration or type use
@Repeatable
can be used anywhere you use a type
Type Annotation
ensures that your variable is not set to null
@NonNull
ensures your number is not negative
@NonNegative
for your zero division exception
@ZeroDivisor
stored in a container annotation that is
automatically generated by the Java compiler
Repeating annotations