首頁  >  文章  >  Java  >  Java進階教學:javadoc輸出什麼

Java進階教學:javadoc輸出什麼

黄舟
黄舟原創
2016-12-27 11:43:371181瀏覽

  javadoc工具將你Java程式的原始程式碼作為輸入,輸出一些包含你程式註解的HTML檔。

  每一個類別的資訊將在獨自的HTML檔案裡。 javadoc也可以輸出繼承的樹狀結構和索引。

  由於javadoc的實作不同,工作也可能不同,你需要檢查你的Java開發系統的版本等細節,選擇合適的Javadoc版本。

  實例

  下面是一個使用說明註釋的簡單實例。注意每一個註釋都在它所描述的項目的前面。

  在經過javadoc處理之後,SquareNum類別的註解將在SquareNum.html中找到。

import java.io.*;
  
/**
* This class demonstrates documentation comments.
* @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 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進階教學:javadoc輸出什麼的內容,更多相關內容請關注PHP中文網(www.php.cn)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn