Core Java學習筆記 注釋

          Posted on 2009-07-17 18:53 eric_xu 閱讀(235) 評論(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

          主站蜘蛛池模板: 枣强县| 郎溪县| 徐闻县| 广宗县| 阳山县| 社会| 贺州市| 来宾市| 大渡口区| 泰来县| 铜山县| 浙江省| 大兴区| 丰镇市| 苏尼特左旗| 泰来县| 封丘县| 巴林左旗| 枞阳县| 西乌| 郁南县| 兴化市| 雅安市| 射阳县| 凤庆县| 芮城县| 惠州市| 庆安县| 余庆县| 普陀区| 天门市| 库尔勒市| 辰溪县| 平陆县| 金华市| 菏泽市| 汝城县| 江川县| 山丹县| 蓬溪县| 房产|