Note: The first is a code-level comment, because the other side code annotations need to read it, makes sense
That he is a comment, because it itself is only explained the role of the code, and does not modify the function annotated code.
2, looks like: @ annotation name
3, three of the most basic annotation system
(1) @Override: representation method is overridden
The compiler checks to a method above marked @Override, will be on the format method checks to see if compliance with the requirements of rewriting.
(2) @SupressWarings: xx warning indicates inhibition
(3) @Deprecated: xx represents Obsolete
When the compiler detects that you have marked using a method such as class or @Deprecated will pop up a warning, not recommended, since it is often such methods are either cumbersome or problematic.
4. Documentation Comments
(1) @author author
(2) @version version
(3) @since initial version
(4) @see reference the like
Interpretation (5) @param Parameters Parameter Name Data Type
(6) @return Return Type Description
(7) @throws exception Type Description
Wherein (5) (6) (7) In the above method, but also to be noted that, @ param parameter write a few few, no I do not write. @return void return type is not written, is not void the need to write, @ throws throw an exception if the type to write, not not write.
If the code is added to the document notes, you can use javadoc.exe tool to generate API.
Documentation Comments:
/ **
documentation comment
* /
5, JUnit few notes
Do not forget the introduction of JUnit library
(1) @Test: indicates that a test method can be a separate method
(2) @ Before / @ After: indicates that this method should be run before each method @Test / rear
(3) @ BeforeClass / @ AfterClass: indicates that this method to run / post until all test methods run only once
Use JUnit class must be public
Mark @ Test, @ Before, @ After the method requires: public void without parameters
Mark @ BeforeClass, @ AfterClass methods require: public static void without parameters
6, custom annotation
(1) syntax
@ Membered annotation [Modifier] @interface annotation name { } @ element annotation [Modifier] {@interface name annotation configuration parameters }
(2) meta-annotation
A: @Target: Description use position annotations
Location 10 ElementType enumerated type constant object to specify
B: @Retention: Description of the life cycle of notes
RetentionPolicy life cycle is specified by the three constant objects: SOURCE, CLASS, RUNTIME
Only RUNTIME stage in order to be reflected to read
C: @Inherited: whether this annotation can be inherited by subclasses
D: @Documented: whether this annotation information can be read into the API javadoc
(3) using a custom annotation What are the requirements
A: When using custom annotations, to look at its @Target, you can see what position
B: When using custom annotations, to see whether there is need to assign configuration parameters
When the annotation configuration parameters need only one assignment, and the parameter name value, you can omit value =