Java注释

Java中的注释

通用注释

下面的标记可以用在类文档的注释中
@author: 作者
@version: 版本
@since: 始于
@deprecated: 不再使用的方法等
@see 引用
@link 引用,同@see
用法:
@see java.lang.String#toString()
@see <a herf="www.google.com>Google</a>"
@see "Core Java 2 volume 2"

类注释

类注释必须放在import语句之后,类定义之前

/**
 * General file manipulation utilities.
 * <p>
 * Facilities are provided in the following areas:
 * <ul>
 * <li>writing to a file
 * <li>reading from a file
 * <li>make a directory including parent directories
 * <li>copying files and directories
 * <li>deleting files and directories
 * <li>converting to and from a URL
 * <li>listing files and directories by filter and extension
 * <li>comparing file content
 * <li>file last changed date
 * <li>calculating a checksum
 * </ul>
 * <p>
 * Origin of code: Excalibur, Alexandria, Commons-Utils
 *
 * @version $Id: FileUtils.java 1349509 2012-06-12 20:39:23Z ggregory $
 */
public class FileUtils {
    ...
}


方法注释

javadoc: 公有的和受保护的构造器及方法
@param: 变量描述
@return: 返回值描述
@throws: 类描述
这个标记将添加一个注释,用于表示这个方法有可能抛出异常

/**
* Construct a file from the set of name elements.
* 
* @param names the name elements
* @return the file
* @since 2.1
*/
public static File getFile(String... names) {
    if (names == null) {
        throw new NullPointerException("names must not be null");
    }
    File file = null;
    for (String name : names) {
        if (file == null) {
            file = new File(name);
        } else {
            file = new File(file, name);
        }
    }
    return file;
}


域注释

只需要对公有域(通常指的是静态常量)建立文档

/**
* The number of bytes in an exabyte.
* 
* @since 2.4
*/
public static final BigInteger ONE_EB_BIONE_KB_BI.multiply(ONE_PB_BI);


注释的抽取

javadoc -d docDirectory nameOfPackage

摘抄于CoreJava, 代码来自于Apache.commons

转载于:https://www.cnblogs.com/uuser/p/5003431.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值