欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java文檔注釋超詳細(xì)講解

 更新時(shí)間:2023年10月07日 15:11:21   作者:太極-彼岸  
這篇文章主要給大家介紹了關(guān)于Java文檔注釋的相關(guān)資料,文檔注釋主要是用來(lái)生成java開(kāi)發(fā)文檔javadoc的,生成的開(kāi)發(fā)文檔和Java本身的API幫助文檔是一樣的,需要的朋友可以參考下

Java只是三種注釋方式。前兩種分別是// 和/* */,第三種被稱作說(shuō)明注釋,它以/** 開(kāi)始,以 */結(jié)束。

說(shuō)明注釋允許你在程序中嵌入關(guān)于程序的信息。你可以使用javadoc工具軟件來(lái)生成信息,并輸出到HTML文件中。

說(shuō)明注釋,是你更加方面的記錄你的程序的信息。

javadoc 標(biāo)簽

javadoc工具軟件識(shí)別以下標(biāo)簽:

標(biāo)簽描述示例
@author標(biāo)識(shí)一個(gè)類的作者@author description
@deprecated指名一個(gè)過(guò)期的類或成員@deprecated description
{@docRoot}指明當(dāng)前文檔根目錄的路徑Directory Path
@exception標(biāo)志一個(gè)類拋出的異常@exception exception-name explanation
{@inheritDoc}從直接父類繼承的注釋Inherits a comment from the immediate surperclass.
{@link}插入一個(gè)到另一個(gè)主題的鏈接{@link name text}
{@linkplain}插入一個(gè)到另一個(gè)主題的鏈接,但是該鏈接顯示純文本字體Inserts an in-line link to another topic.
@param說(shuō)明一個(gè)方法的參數(shù)@param parameter-name explanation
@return說(shuō)明返回值類型@return explanation
@see指定一個(gè)到另一個(gè)主題的鏈接@see anchor
@serial說(shuō)明一個(gè)序列化屬性@serial description
@serialData說(shuō)明通過(guò)writeObject( ) 和 writeExternal( )方法寫(xiě)的數(shù)據(jù)@serialData description
@serialField說(shuō)明一個(gè)ObjectStreamField組件@serialField name type description
@since標(biāo)記當(dāng)引入一個(gè)特定的變化時(shí)@since release
@throws和 @exception標(biāo)簽一樣.The @throws tag has the same meaning as the @exception tag.
{@value}顯示常量的值,該常量必須是static屬性。Displays the value of a constant, which must be a static field.
@version指定類的版本@version info

文檔注釋

在開(kāi)始的/**之后,第一行或幾行是關(guān)于類、變量和方法的主要描述.

之后,你可以包含一個(gè)或多個(gè)何種各樣的@標(biāo)簽。每一個(gè)@標(biāo)簽必須在一個(gè)新行的開(kāi)始或者在一行的開(kāi)始緊跟星號(hào)(*).

多個(gè)相同類型的標(biāo)簽應(yīng)該放成一組。例如,如果你有三個(gè)@see標(biāo)簽,可以將它們一個(gè)接一個(gè)的放在一起。

下面是一個(gè)類的說(shuō)明注釋的示例:

/*** This class draws a bar chart.
* @author Zara Ali
* @version 1.2
*/

javadoc輸出什么

javadoc工具將你Java程序的源代碼作為輸入,輸出一些包含你程序注釋的HTML文件。

每一個(gè)類的信息將在獨(dú)自的HTML文件里。javadoc也可以輸出繼承的樹(shù)形結(jié)構(gòu)和索引。

由于javadoc的實(shí)現(xiàn)不同,工作也可能不同,你需要檢查你的Java開(kāi)發(fā)系統(tǒng)的版本等細(xì)節(jié),選擇合適的Javadoc版本。

實(shí)例

下面是一個(gè)使用說(shuō)明注釋的簡(jiǎn)單實(shí)例。注意每一個(gè)注釋都在它描述的項(xiàng)目的前面。

在經(jīng)過(guò)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
$

總結(jié) 

到此這篇關(guān)于Java文檔注釋的文章就介紹到這了,更多相關(guān)Java文檔注釋內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java分布式面試CAP分別代表含義分析

    java分布式面試CAP分別代表含義分析

    這篇文章主要為大家介紹了java分布式面試中關(guān)于CAP分別代表含義的問(wèn)題分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2022-03-03
  • Java中的CyclicBarrier循環(huán)柵欄解析

    Java中的CyclicBarrier循環(huán)柵欄解析

    這篇文章主要介紹了Java中的CyclicBarrier循環(huán)柵欄解析,從字面上的意思可以知道,這個(gè)類的中文意思是"循環(huán)柵欄",大概的意思就是一個(gè)可循環(huán)利用的屏障,它的作用就是會(huì)讓所有線程都等待完成后才會(huì)繼續(xù)下一步行動(dòng),需要的朋友可以參考下
    2023-12-12
  • 詳解Java內(nèi)存管理中的JVM垃圾回收

    詳解Java內(nèi)存管理中的JVM垃圾回收

    這篇文章給大家分享了關(guān)于Java內(nèi)存管理中的JVM垃圾回收的相關(guān)知識(shí)點(diǎn)內(nèi)容,有興趣的朋友們可以學(xué)習(xí)參考下。
    2018-08-08
  • 淺談使用setBounds()方法需要注意的地方

    淺談使用setBounds()方法需要注意的地方

    下面小編就為大家?guī)?lái)一篇淺談使用setBounds()方法需要注意的地方。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-05-05
  • java實(shí)現(xiàn)單詞搜索迷宮游戲

    java實(shí)現(xiàn)單詞搜索迷宮游戲

    這篇文章主要介紹了java實(shí)現(xiàn)單詞搜索迷宮游戲,實(shí)例分析了迷宮游戲的實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2015-05-05
  • SpringBoot?AOP中JoinPoint的使用方式和通知切點(diǎn)表達(dá)式

    SpringBoot?AOP中JoinPoint的使用方式和通知切點(diǎn)表達(dá)式

    這篇文章主要介紹了SpringBoot?AOP中JoinPoint的使用方式和通知切點(diǎn)表達(dá)式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Spring @Bean vs @Service注解區(qū)別

    Spring @Bean vs @Service注解區(qū)別

    本篇文章主要介紹了Spring @Bean vs @Service注解區(qū)別,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-12-12
  • Spring框架配置java web實(shí)現(xiàn)實(shí)例化

    Spring框架配置java web實(shí)現(xiàn)實(shí)例化

    這篇文章主要介紹了Spring框架配置java web實(shí)現(xiàn)實(shí)例化,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • 如何獲取springboot打成jar后的classpath

    如何獲取springboot打成jar后的classpath

    這篇文章主要介紹了如何獲取springboot打成jar后的classpath問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Java?IO篇之Reactor?網(wǎng)絡(luò)模型的概念

    Java?IO篇之Reactor?網(wǎng)絡(luò)模型的概念

    Reactor?模式也叫做反應(yīng)器設(shè)計(jì)模式,是一種為處理服務(wù)請(qǐng)求并發(fā)提交到一個(gè)或者多個(gè)服務(wù)處理器的事件設(shè)計(jì)模式,Reactor?模式主要由?Reactor?和處理器?Handler?這兩個(gè)核心部分組成,本文給大家介紹Java?IO篇之Reactor?網(wǎng)絡(luò)模型的概念,感興趣的朋友一起看看吧
    2022-01-01

最新評(píng)論