Detailed java custom annotations

table of Contents

One, custom annotation grammatical structure

Second, the attribute syntax structure


One, custom annotation grammatical structure

Second, the attribute syntax structure

Example:

Note :
(1) An annotation attribute has no default value by default . If an annotation attribute with no default value is defined in the annotation, the value must be specified when using the annotation :

No default value

If the annotation value attribute has no default and no specific value is set when used, the code syntax will not pass.

(2) If the annotation attribute is named value , you can directly assign a value when using the annotation

Direct assignment {"deprecation"}

(3) If the annotation data type of the attribute is an array type , must be used when a value more than {} enclosed ; but if only assigned a value, instead of using {} :

 

 

Guess you like

Origin blog.csdn.net/m0_46383618/article/details/113530593