Core Java学习笔记 注释

Posted on 2009-07-17 18:53 eric_xu 阅读(216) 评论(0)  编辑  收藏 所属分类: Java

注释

 

文件头注释

文件头注释以 /*开始,以*/结束,需要注明该文件创建时间,文件名,命名空间信息。

例如:

/*

 * @(#)Boolean.java  1.51 04/05/11

 *

 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.

 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.

 */

 

类、接口注释

类、接口的注释采用 /** … */,描述部分用来书写该类的作用或者相关信息,块标记部分必须注明作者和版本。Import语句之后,类定义之前。

例如:

/**

 * The Boolean class wraps a value of the primitive type

 * <code>boolean</code> in an object. An object of type

 * <code>Boolean</code> contains a single field whose type is

 * <code>boolean</code>.

 * <p>

 * In addition, this class provides many methods for

 * converting a <code>boolean</code> to a <code>String</code> and a

 * <code>String</code> to a <code>boolean</code>, as well as other

 * constants and methods useful when dealing with a

 * <code>boolean</code>.

 *

 * @author  Arthur van Hoff

 * @version 1.51, 05/11/04

 * @since   JDK1.0

 */

 

方法注释采用/** … */,描述部分注明方法的功能,块标记部分注明方法的参数,返回值,异常等信息。

/**

* Compares this <tt>Boolean</tt> instance with another.

*

* @param   b the <tt>Boolean</tt> instance to be compared

* @return  zero if this object represents the same boolean value as the

*          argument; a positive value if this object represents true

*          and the argument represents false; and a negative value if

*          this object represents false and the argument represents true

* @throws  NullPointerException if the argument is <tt>null</tt>

* @see     Comparable

* @since  1.5

*/

@param后面空格后跟着参数的变量名字(不是类型),空格后跟着对该参数的描述。

@return标记返回为空(void)的构造函数或者函数,@return可以省略。

如果返回值就是输入参数,必须用与输入参数的@param相同的描述信息。

必要的时候注明特殊条件写的返回值。

@deprecated由于某种原因而被宣布将要被废弃的方法。

@see:引用其它类的文档,相当于超链接,Javadoc会在其生成的HTML文件中,将@see标签链到其他的文档

@see package.classname#feature label

@see <a href=”…”>label</a>

@see “text”

@link标记

语法:{@link package.class#member label}

Label为链接文字。

package.class#member将被自动转换成指向package.classmember文件的URL

@since

类注释标记。

标明该类可以运行的JDK版本

 


只有注册用户登录后才能发表评论。


网站导航:
 

posts - 37, comments - 5, trackbacks - 0, articles - 0

Copyright © eric_xu