Preface:
Why should we study notes?
Annotations are our programming more concise. Popular spring boot also led to the comment. spring boot on the use of a large number of notes to reduce the configuration. We use spring boot development, I felt very concise. This is the comment of credit. Also notes the development of a trend. So, we are still very necessary to learn annotations.
Take a look "Java- Kaige Notes" series of main content
9c7b894d2669b3973083af9ab2b0c672.png
This article explains the former three: annotation defined, JDK built-in notes, third-party comments.
A: annotation defines
Take a look at how to say on Wikipedia:
836f71571324abf8cbd3d8f35959ee1d.png
It appears after JDK 1.5, metadata ....... Hard to understand. Saying:
Annotations can be understood as a logo, it is to give the code of the tag. Labels which can have other attributes. When parsed, based on the class is not a lay mark. If there is, OK, it parses the label inside the property. Following figure summarizes:
11c80b8326fa31621f634b4059342a1f.png
Two: JDK built-in annotations
a119791a0fe682ef51ebc6164f5a1ab4.png
JDK built three notes were: @ Override, @ Deprecated, @ Suppvieswarnings
@Override: rewrite coverage. This is more common in JAVA we are also called to rewrite. Used between the parent-child class or interface implementation class. Subclasses override the parent class or classes implement methods. For example, rewrite toString method. Subclasses override inherited methods.
@Deprecated: outdated, obsolete. Generally in the new version will replace or interface will be in the next version is discarded.
Such as: Calendar, there are many such classes.
851fdfb60b4a933ef9bc098afd7506a3.png
e7c8d6f246dfd812905dde8990bacb08.png
@Suppvieswarnings: compression warning for notifying the Java compiler to ignore the characteristics of compiler warnings. As we declare a property is not used. There may be prompted. After using this annotation you can ignore the warning.
Three: the third-party comments.
Third-party comments, is the most used in our work, but also on the role of our greatest. Common spring notes. As shown below
f1ab0b9a5a6d546e9d681348ad84eb48.png
Disclaimer: This article explains the first article in a series of tutorials Kaige Java Java annotations.
This article Source: http://www.kaigejava.com/article/detail/439
Kaige blog: www.kaigejava.com
Kaige public number: Kaige Java (kaigejava)