- Annotation define a new type of keyword use @interface
- Custom annotation automatically inherited java.lang.annotation.Annotation Interface
- Annotation Annotation definition of member variables in the form of non-parametric methods are declared. Its method name and return value defines the name and type of the member. We called configuration parameters . Type only eight basic data types, String type, Class type, enum type, Annotation type, all of the above types of arrays.
- You can assign initial values when member variables defined Annotation, specifying the initial value of the member variables can use the default keyword
- If only one member of parameters, it is recommended to use a parameter called value
- If a comment contains a defined configuration parameters, you must specify parameter values when in use, unless it has a default value . The format is "parameter name = parameter value", if only one member of the parameter, and name value, you can omit "value ="
- No members defined Annotation called marker; Annotation containing member variables called metadata Annotation
Note:
Custom annotations must be accompanied by an information processing flow is meaningful annotations.
@MyAnnotation(value="尚硅谷") public class MyAnnotationTest {
}
@interface MyAnnotation{ String value() default "auguigu";
}