更新時(shí)間:2022-05-12 10:38:34 來(lái)源:動(dòng)力節(jié)點(diǎn) 瀏覽1344次
Java 代碼中的大多數(shù)普通注釋都解釋了該代碼的實(shí)現(xiàn)細(xì)節(jié)。相反,Java 語(yǔ)言規(guī)范定義了一種特殊類(lèi)型的注釋?zhuān)Q(chēng)為文檔注釋?zhuān)糜谟涗洿a的 API。
文檔注釋是一個(gè)普通的多行注釋?zhuān)?**(而不是通常的/*)開(kāi)頭并以*/結(jié)尾. 文檔注釋出現(xiàn)在類(lèi)、接口、方法或字段定義之前,并包含該類(lèi)、接口、方法或字段的文檔。文檔可以包括簡(jiǎn)單的 HTML 格式標(biāo)記和其他提供附加信息的特殊關(guān)鍵字。文檔注釋會(huì)被編譯器忽略,但它們可以被javadoc 程序提取并自動(dòng)轉(zhuǎn)換為在線(xiàn) HTML 文檔。這是一個(gè)包含適當(dāng)文檔注釋的示例類(lèi): docstore.mik.ua/orelly/java-ent/jnut/ch07_03.htm
/**
* This immutable class represents complex
* numbers. *
* @author David Flanagan
* @version 1.0
*/
public class Complex {
/**
* Holds the real part of this complex number.
* @see #y
*/
protected double x;
/**
* Holds the imaginary part of this complex number.
* @see #x
*/
protected double y;
/**
* Creates a new Complex object that represents the complex number
* x+yi.
* @param x The real part of the complex number.
* @param y The imaginary part of the complex number.
*/ public Complex(double x, double y) { this.x = x; this.y = y; }
/**
* Adds two Complex objects and produces a third object that represents
* their sum.
* @param c1 A Complex object
* @param c2 Another Complex object
* @return A new Complex object that represents the sum of
* c1 and
* c2.
* @exception java.lang.NullPointerException
* If either argument is null.
*/ public Complex add(Complex c1, Complex c2) { return new Complex(c1.x + c2.x, c1.y + c2.y); } } docstore.mik.ua/orelly/java-ent/jnut/ch07_03.htm
相關(guān)閱讀
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
有基礎(chǔ) 直達(dá)就業(yè)
業(yè)余時(shí)間 高薪轉(zhuǎn)行
工作1~3年,加薪神器
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問(wèn)老師會(huì)電話(huà)與您溝通安排學(xué)習(xí)
初級(jí) 202925
初級(jí) 203221
初級(jí) 202629
初級(jí) 203743