Annotation深入研究——@Documented注释使用


 

 

Documented注释的作用及其javadoc文档生成工具的使用

代码放在MyDocumentedtAnnotationDemo.java文件中

package org.yu.demo16.documentedannotation ;

import java.lang.annotation.Documented ;

@MyDocumentedtAnnotation(key="小雨",value="中国地质大学")

public class MyDocumentedtAnnotationDemo{

        

         @MyDocumentedtAnnotation(key="小雨",value="中国地质大学")

         public String toString(){

                   return "hello yu..." ;

         }

};

 

@Documented

@interface MyDocumentedtAnnotation{

         public String key() default "yu" ;

         public String value() default "cug" ;

}

仔细看看下面的编译的结果:

在java文件所在的路径中可以发现生成了doc文件夹,打开文件夹,打开index.html可以发现查看生成的文档

下面是Documented注释用在类上的作用:给类添加注释

下面是Documented注释用在类方法上的作用:给类方法添加注释

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM