**** # 1.內容 | | 解釋 | | | | | // 內容 | 單行註釋 | | /* 內容 */ | 多行註釋 | | /*** 內容 */ | 文檔註釋 | # 2.多行註釋 與 文檔註釋的區別 多行註釋: ![img](https://img2023.cnblogs.com/blog ...
1.內容
解釋 | |
---|---|
// 內容 | 單行註釋 |
/* 內容 */ | 多行註釋 |
/*** 內容 */ | 文檔註釋 |
2.多行註釋 與 文檔註釋的區別
多行註釋:
文檔註釋:JDK提供工具javadoc解析 註釋的內容,為生成API文檔做準備
3.生成步驟
4.javadoc標簽
標簽 | 描述 | 示例 |
---|---|---|
@author | 作者 | @author liudelantu |
@deprecated | 指名一個過期的類或成員 | @deprecated description |
{@docRoot} | 指明當前文檔根目錄的路徑 | Directory Path |
@exception | 標誌一個類拋出的異常 | @exception exception-name explanation |
{@inheritDoc} | 從直接父類繼承的註釋 | Inherits a comment from the immediate surperclass. |
{@link} | 插入一個到另一個主題的鏈接 | {@link name text} |
{@linkplain} | 插入一個到另一個主題的鏈接,但是該鏈接顯示純文本字體 | Inserts an in-line link to another topic. |
@param | 說明一個方法的參數 | @param parameter-name explanation |
@return | 說明返回值類型 | @return explanation |
@see | 指定一個到另一個主題的鏈接 | @see anchor |
@serial | 說明一個序列化屬性 | @serial description |
@serialData | 說明通過writeObject( ) 和 writeExternal( )方法寫的數據 | @serialData description |
@serialField | 說明一個ObjectStreamField組件 | @serialField name type description |
@since | 標記當引入一個特定的變化時 | @since release |
@throws | 和 @exception標簽一樣. | 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 1.0 |
5.規範
類,方法的註釋,要用javadoc的方式寫,為了在生成的API文檔上 說明此類或方法的用途