Java 文檔注釋.

來源:互聯網
上載者:User

標籤:1.2   dem   auth   des   ges   多個   項目   reader   turn   

文檔注釋
在開始的 / 之後,第一行或幾行是關於類、變數和方法的主要描述。
之後,你可以包含一個或多個何種各樣的 @ 標籤。每一個 @ 標籤必須在一個新行的開始或者在一行的開始緊跟星號().
多個相同類型的標籤應該放成一組。例如,如果你有三個 @see 標籤,可以將它們一個接一個的放在一起。
下面是一個類的說明注釋的執行個體:
/
這個類繪製一個橫條圖

  • @author runoob
  • @version 1.2
    /
    javadoc 輸出什麼
    javadoc 工具將北京股票配資Java 程式的原始碼作為輸入,輸出一些包含你程式注釋的HTML檔案。
    每一個類的資訊將在獨自的HTML檔案裡。javadoc 也可以輸出繼承的樹形結構和索引。
    由於 javadoc 的實現不同,工作也可能不同,你需要檢查你的 Java 開發系統的版本等細節,選擇合適的 Javadoc 版本。
    執行個體
    下面是一個融金匯銀使用說明注釋的簡單一實例。注意每一個注釋都在它描述的項目的前面。
    在經過 javadoc 處理之後,SquareNum 類的注釋將在 SquareNum.html 中找到。
    SquareNum.java 檔案代碼:
    import java.io.
    ;

/**

  • 這個類示範了文檔注釋
  • @author Ayan Amhed
  • @version 1.2
    */
    public class SquareNum {
    /**
    • This method returns the square of num.
    • This is a multiline description. You can use
    • as many lines as you like.
    • @param num The value to be squared.
    • @return num squared.
      /
      public double square(double num) {
      return num
      num;
      }
      /**
    • This method inputs a number from the user.
    • @return The value input as a double.
    • @exception IOException On input error.
    • @see IOException
      */
      public double getNumber() throws IOException {
      InputStreamReader isr = new InputStreamReader(System.in);
      BufferedReader inData = new BufferedReader(isr);
      String str;
      str = inData.readLine();
      return (new Double(str)).doubleValue();
      }
      /**
    • This method demonstrates square().
    • @param args Unused.
    • @return Nothing.
    • @exception IOException On input error.
    • @see IOException
      */
      public static void main(String args[]) throws IOException
      {
      SquareNum ob = new SquareNum();
      double val;
      System.out.println("Enter value to be squared: ");
      val = ob.getNumber();
      val = ob.square(val);
      System.out.println("Squared value is " + val);
      }
      }
      如下,使用 javadoc 工具處理 SquareNum.java 檔案:
      $ javadoc SquareNum.java
      Loading source file SquareNum.java...
      Constructing Javadoc information...
      Standard Doclet version 1.5.0_13
      Building bjrongjinhuiyin.com tree for all the packages and classes...
      Generating SquareNum.html...
      SquareNum.java:39: warning - @return tag cannot be used\
      in method with void return type.
      Generating package-frame.html...
      Generating package-summary.html...
      Generating package-tree.html...
      Generating constant-values.html...
      Building index for all the packages and classes...
      Generating overview-tree.html...
      Generating index-all.html...
      Generating deprecated-list.html...
      Building index for all classes...
      Generating allclasses-frame.html...
      Generating allclasses-noframe.html...
      Generating index.html...
      Generating help-doc.html...
      Generating stylesheet.css...
      1 warning
      $

Java 文檔注釋.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.