ホームページ  >  記事  >  Java  >  上級 Java チュートリアル: javadoc は何を出力しますか?

上級 Java チュートリアル: javadoc は何を出力しますか?

黄舟
黄舟オリジナル
2016-12-27 11:43:371182ブラウズ

javadoc ツールは、Java プログラムのソース コードを入力として受け取り、プログラムに関するコメントを含むいくつかの HTML ファイルを出力します。

各クラスの情報は別のHTMLファイルになります。 Javadoc は、継承されたツリー構造とインデックスを出力することもできます。

Javadoc の実装が異なるため、作業も異なる場合があります。Java 開発システムのバージョンやその他の詳細を確認して、適切な Javadoc バージョンを選択する必要があります。

以下は命令アノテーションを使用する簡単な例です。各コメントは、説明する項目の前にあることに注意してください。

SquareNumクラスのコメントはjavadocで処理された後、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 中国語 Web サイト (www.php.cn) に注目してください。


声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。