@Documented
时间: 2024-01-19 18:03:32 浏览: 64
JDK 5 提供的注解:Target、Inherited和Documented的区别
The `@Documented` annotation is a meta-annotation in Java that is used to indicate that the annotated element should be included in the generated documentation. When this annotation is applied to any other annotation declaration, the Javadoc tool includes the annotated element's documentation in the generated API documentation.
For example, if we have an annotation called `MyAnnotation` and we add the `@Documented` annotation to its declaration, any class or method that uses the `MyAnnotation` annotation will have its documentation included in the generated Javadoc.
Here is an example of how to use the `@Documented` annotation:
```
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MyAnnotation {
String value() default "default value";
}
```
In this example, we have added the `@Documented` annotation to our `MyAnnotation` annotation. Now, any classes or methods that use `MyAnnotation` will have their documentation included in the generated Javadoc.
阅读全文