Java doc简单说明

javadoc 标记是插入文档注释中的特殊标记,它们用于标识代码中的特殊引用。javadoc 标记由“@”及其后所跟的标记类型和专用注释引用组成。三个部分——@、标记类型、专用注释引用。可以分成两部分:@ 和标记类型、专用注释引用。虽然 @ 和 标记类型之间有时可以用空格符分隔,但是最好始终将它们紧挨着写,以减少出错机会。

这些是注释类,属性和方法的。 简述是注释的第一个‘.’之前的所有内容。

javadoc通常从package、公开类或者接口、公开或者受保护的字段、公开或者受保护的方法提取信息。每条注释应该是以/**开始以*/结尾。例如

    /**
    * 
    * @param id the coreID of the person
    * @param userName the name of the person

    * you should use the constructor to create a person object
    */
    public SecondClass(int id,String userName)
    {
       this.id = id;
       this.userName = userName;
    }

注释应该写在要说明部分的前面,如上所示。并且在其中可以包括html的标记,如果上面没有标记的话,那么you should usr the ……将会在javadoc里面紧跟@param userName….,这样不是我们希望的。一般注释可以分为类注释、方法注释、字段注释等。下面分别作简单的介绍

类注释
类注释应该在import语句的后面在类声明的前面,比如

package com.north.java;
 /**
 * @author ming
 * 
 * this interface is to define a method print()

 * you should implements this interface is you want to print the username

 * @see com.north.ming.MainClass#main(String[])
 */
public interface DoSomething
{
    /**
     * @param name which will be printed  
     * @return nothing will be returned 
     *
     */
    public void print(String name);
}

其中@author 和@see都是常用的注释第一个表示作者,第二个表示参考的连接。

方法注释
方法注释要紧靠方法的前面,你可以在其中使用@param @return @throws等标签。例如

     /**
     * 
     * @param i
     * @return true if ..... else false
     * @throws IOException when reading the file ,if something wrong happened
     * then the method will throws a IOException
     */
    public boolean doMethod(int i) throws IOException
    {
        return true;
    }

字段注释
只有public的字段才需要注释,通常是static德,例如

    /**
     * the static filed hello
     */
    public static int hello = 1;



总结:

标记用于作用用法例子
@author对类的说明标明开发该类模块的作者@author 作者名可以使用多次,多个作者使用,隔开
@version对类的说明标明该类模块的版本@version 版本号可以使用多次,但只用第一次生效
@see对类、属性、方法的说明参考转向,也就是相关主题@see 类名;@see #方法名或属性名; @see 类名#方法名或属性名@see #count(属性); @see #show(boolean b)(方法)
@param对方法的说明对方法中某参数的说明@param 参数名 参数说明@param b excrescent parameter
@return对方法的说明对方法返回值的说明@return 返回值说明@return true or false
@exception对方法的说明对方法可能抛出的异常进行说明@exception 异常类名 说明@exception java.lang.Exception throw when switch is 1
@throws:异常同exceptioin



还有一种就是:
TODO://Created on:
这类的注释我只了解到这一个。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值