日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

Javadoc注释规范

發布時間:2025/3/21 java 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Javadoc注释规范 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Javadoc雖然是Sun公司為Java文檔自動生成設計的,可以從程序源代碼中抽取類、方法、成員等注釋形成一個和源代碼配套的API幫助文檔。(Javadoc is a documentation generator from Sun Microsystems for generating API documentation in HTML format from Java source code. -- 維基百科)但是Javadoc的注釋也符合C的注釋格式,而且doxyen也支持該種風格的注釋,所以簡單學習一下。以下的內容來自官方文檔,維基百科和一些網上的文檔。

  官方文檔:http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html

  維基百科:http://en.wikipedia.org/wiki/Javadoc

  Javadoc的注釋結構和C類似。都以/* 注釋 */這種結構。

?? ? Javadoc的內容很多,我只是先學習一下Overview注釋,類注釋和方法注釋,其他的以后再學。先貼出幾段Java的示例代碼。

Overview:

?

/** ????* @author????? Firstname Lastname <address @ example.com> ????* @version???? 2010.0331???????????????????????????????? (E.g. ISO 8601 YYYY.MMDD) ????* @since?????? 1.6?????????????????????????????????????? (The Java version used) ????*/ ???public?class?Test { ?????// class body ???}

Class:

?

?

/** ?* A class representing a window on the screen. ?* For example: ?* <pre> ?*??? Window win = new Window(parent); ?*??? win.show(); ?* </pre> ?* ?* @author? Sami Shaio ?* @version %I%, %G% ?* @see???? java.awt.BaseWindow ?* @see???? java.awt.Button ?*/ class?Window extends?BaseWindow { ???... }

Method:

?

?

/** ?????* Returns the character at the specified index. An index ?????* ranges from <code>0</code> to <code>length() - 1</code>. ?????* ?????* @param???? index? the index of the desired character. ?????* @return??? the desired character. ?????* @exception StringIndexOutOfRangeException ?????*????????????? if the index is not in the range <code>0</code> ?????*????????????? to <code>length()-1</code>. ?????* @see?????? java.lang.Character#charValue() ?????*/ ????public?char?charAt(int?index) { ???????... ????}

其實這些注釋形式都差不多,主要是tag不同下面介紹一下tag及含義。


Overview Tags
@see
@since
@author
@version
{@link}
{@linkplain}
{@docRoot}
Class/Interface Tags
@see
@since
@deprecated
@serial
@author
@version
{@link}
{@linkplain}
{@docRoot}
Method/Constructor Tags
@see
@since
@deprecated
@param
@return
@throws?and?@exception
@serialData
{@link}
{@linkplain}
{@inheritDoc}
{@docRoot}

Tag & ParameterUsageApplies toSince
@author?nameDescribes an author.
描述作者
Class, Interface?
@version?versionProvides version entry. Max one per Class or Interface.
版本條目,每個類或接口最多有一個
Class, Interface?
@since?since-textDescribes since when this functionality has existed.
描述這個功能塊從何時有的
Class, Interface, Field, Method?
@see?referenceProvides a link to other element of documentation.
提供鏈接到其他文檔元素的鏈接
Class, Interface, Field, Method?
@param?name descriptionDescribes a method parameter.
描述一個參數
Method?
@return?descriptionDescribes the return value.
描述返回值
Method?
@exception?classname description
@throws?classname description
Describes an exception that may be thrown from this method.
描述該方法可能拋出的異常
Method?
@deprecated?descriptionDescribes an outdated method.
描述一個過期的方法
Method?
{@inheritDoc}Copies the description from the overridden method.
從復寫方法出拷貝來得描述
Overriding Method1.4.0
{@link?reference}Link to other symbol.
連到其他的引用
Class, Interface, Field, Method?
{@value}Return the value of a static field.
返回一個靜態作用域的值
Static Field1.4.0



from:?http://www.cnblogs.com/allen8807/archive/2010/11/10/1873703.html

總結

以上是生活随笔為你收集整理的Javadoc注释规范的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。