Annotations
Annotations are a special type of metadata that can be added to your code to inform the compiler about relevant aspects of it. Annotations can be used during the declaration of classes, fields, methods, variables, and parameters. One interesting aspect of annotations is that they remain visible inside classes, indicating whether a method is an override to a different one from a parent class, for example.
Annotations are declared using the @
symbol followed by the annotation's name. There are some built-in annotations, but it is also possible to declare your own. At this point, it is important to focus on some of the built-in ones, as it will help you to understand some of the concepts presented so far in this chapter
The most relevant built-in annotations are @Override
, @Deprecated
, and @SuppressWarnings
. These three commands inform the compiler about different aspects of the code or the process of producing it.
@Override
is used to indicate that a method...