Fresh Energy

           Nerver say die!

IT博客 首页 新随笔 联系 聚合 管理
  84 Posts :: 0 Stories :: 197 Comments :: 0 Trackbacks
1.整个类文件注释

示例如下:

/*

 * @(#)Object.java     1.61 03/01/23

 *

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

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

 */

 

注释结构:

/*

 * @(#){类名称}.java       {创建时间}

 *

 * {某人或某公司具有完全的版权}

 * {使用者必须经过许可}

 */

 

2.     具体类功能注释

示例如下:

/**

 * Class <code>Object</code> is the root of the class hierarchy.

 * Every class has <code>Object</code> as a superclass. All objects,

 * including arrays, implement the methods of this class.

 *

 * @author unascribed

 * @version 1.61, 01/23/03

 * @see     java.lang.Class

 * @since   JDK1.0

 */

public class Object {}

 

注释结构:

/**

 * <code>{类名称}</code>{此类功能描述}

 *

 * @author {作者}

 * @version {版本,常用时间代替}

 * @see     java.lang.Class

 * @since   JDK{jdk版本}

 */

public class Object {}

 

3.     类变量注释

示例如下:

/** The value is used for character storage. */

 private char value[];

 

注释结构:

 /** {此值是用来存储/记录什么的}*/

 private String str ;

 

4.     类方法注释

示例如下:

    /**

     * Returns a new string that is a substring of this string. The

     * substring begins with the character at the specified index and

     * extends to the end of this string. <p>

     * Examples:

     * <blockquote><pre>

     * "unhappy".substring(2) returns "happy"

     * "Harbison".substring(3) returns "bison"

     * "emptiness".substring(9) returns "" (an empty string)

     * </pre></blockquote>

     *

     * @param      beginIndex   the beginning index, inclusive.

     * @return     the specified substring.

     * @exception IndexOutOfBoundsException if

     *             <code>beginIndex</code> is negative or larger than the

     *             length of this <code>String</code> object.

     */

public String substring(int beginIndex) {

return substring(beginIndex, count);

}

 

注释结构:

    /**

     * {方法的功能/动作描述}

     *

     * @param      {引入参数名}   {引入参数说明}

     * @return      {返回参数名}   {返回参数说明}

     * @exception  {说明在某情况下,将发生什么异常}

     */

public String substring(int beginIndex) {

return substring(beginIndex, count);

}

 

 

5.     类方法中代码块注释

注释结构:

/*

* {功能描述}

*

* {具体实现动作}

*/

 

posted on 2008-04-24 20:42 zhouditty 阅读(1776) 评论(1)  编辑 收藏 引用 所属分类: Java程序设计

Feedback

# re: JAVA代码注释规则 2008-04-27 21:08 踏雪赤兔
记得先揾下有冇生成注释代码嘅插件~应该电脑做嘅嘢就唔好自己做啦~  回复  更多评论
  

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