当前位置: java基础教程 > 25-javadoc文档 > 阅读正文

编写javadoc注释

2021.3.9.   1100 次   1113字

javadoc 是从java文档注释中提取出来的

文档注释, 语法格式为: /** 自由文本 */ , 自由文本需要注意以下 2 点

  • 自由文本可以使用 html 标签, 如 em,strong,ul,img,code
  • 自由文本中使用javadoc标签,这些标签是jdk预定义的,能够被识别
javadoc标签

关于javadoc标签可以从oracle官网上查看, 点击这里跳转, 下面仅简要概述

通常写在 2 个位置, ①类上, ②方法上,

javadoc标签的作用如下:

标签描述示例
@author标识维护的作者, 多个作者时使用多个 @author@author description
@deprecated指名一个过期的类或成员@deprecated description
{@docRoot}指明当前文档根目录的路径Directory Path
@exception用于描述方法签名throws对应的异常@exception exception-name explanation
{@inheritDoc}@inheritDoc用于注解在重写方法或者子类上,用于继承父类中的JavadocInherits a comment from the immediate surperclass.
{@link}插入一个跳转相关资源的链接{@link name text}
{@linkplain}插入一个到另一个主题的链接,但是该链接显示纯文本字体Inserts an in-line link to another topic.
@param@param 后面跟参数名,再跟参数描述@param parameter-name explanation
@return说明返回值类型@return explanation
@see请另外参考其他类或方方法@see anchor
@serial说明一个序列化属性@serial description
@serialData说明通过writeObject( ) 和 writeExternal( )方法写的数据@serialData description
@serialField说明一个ObjectStreamField组件@serialField name type description
@since表示从以下版本开始@since 1.8
@throws用于描述方法内部可能抛出的异常The @throws tag has the same meaning as the @exception tag.
{@value}显示常量的值,常量是static finalDisplays the value of a constant, which must be a static field.
@version@version 用于标记当前版本@version info

本篇完,还有疑问?

加入QQ交流群:11500065636 IT 技术交流群