整個類檔案注釋
樣本如下 :
/*
* @(#)Object.java 1.61 03/01/23
*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package java.lang;
注釋結構 :
/*
* @(#){ 類名稱 }.java { 建立時間 }
*
* { 某人或某公司具有完全的著作權 }
* { 使用者必須經過許可 }
*/
package java.lang;
2. 具體類功能注釋
樣本如下 :
/**
* Class <code>Object</code> is the root of the class hierarchy.
* Every class has <code>Object</code> as a superclass. All objects,
* including arrays, implement the methods of this class.
*
* @author unascribed
* @version 1.61, 01/23/03
* @see java.lang.Class
* @since JDK1.0
*/
public class Object {}
注釋結構 :
/**
* 類 <code>{ 類名稱 }</code>{ 此類功能描述 }
*
* @author { 作者 }
* @version { 版本 , 常用時間代替 }
* @see java.lang.Class
* @since JDK{jdk 版本 }
*/
public class Object {}
3. 類變數注釋
樣本如下 :
/** The value is used for character storage. */
private char value[];
注釋結構 :
/** { 此值是用來儲存 / 記錄什麼的 }*/
private String str ;
4. 類方法注釋
樣本如下 :
/**
* Returns a new string that is a substring of this string. The
* substring begins with the character at the specified index and
* extends to the end of this string. <p>
* Examples:
* <blockquote><pre>
* "unhappy".substring(2) returns "happy"
* "Harbison".substring(3) returns "bison"
* "emptiness".substring(9) returns "" (an empty string)
* </pre></blockquote>
*
* @param beginIndex the beginning index, inclusive.
* @return the specified substring.
* @exception IndexOutOfBoundsException if
* <code>beginIndex</code> is negative or larger than the
* length of this <code>String</code> object.
*/
public String substring(int beginIndex) {
return substring(beginIndex, count);
}
注釋結構 :
/**
* { 方法的功能 / 動作描述 }
*
* @param { 引入參數名 } { 引入參數說明 }
* @return { 返回參數名 } { 返回參數說明 }
* @exception { 說明在某情況下 , 將發生什麼異常 }
*/
public String substring(int beginIndex) {
return substring(beginIndex, count);
}
5. 類方法中代碼塊注釋
樣本如下 :
/*
* 調用持久化類,將資料儲存到庫
*
* 判斷是添加,還是修改
*/
boolean ifSucc = false;
if(request.getParameter("YINGLI_ID")==null){
String GUID = new RandomGUID().toString();
stressTestDataBean.setUSER_ID(Integer.toString(userId));
stressTestDataBean.setSIGN_ISBN((String)vSectNum.get(0));
stressTestDataBean.setSHENHE_JIEGUO("0");
stressTestDataBean.setGUID(GUID);
stressTestDataBean.setCREATE_DATE("getdate()");
stressTestDataBean.setSTATE("A");
ifSucc = StressTestDataDao.addStressTestData(db,stressTestDataBean);
}else{
ifSucc = StressTestDataDao.mendStressTestData(db,stressTestDataBean);
}
注釋結構 :
/*
* { 功能描述 }
*
* { 具體實現動作 }
*/
boolean ifSucc = false;
if(request.getParameter("YINGLI_ID")==null){
String GUID = new RandomGUID().toString();
stressTestDataBean.setUSER_ID(Integer.toString(userId));
stressTestDataBean.setSIGN_ISBN((String)vSectNum.get(0));
stressTestDataBean.setSHENHE_JIEGUO("0");
stressTestDataBean.setGUID(GUID);
stressTestDataBean.setCREATE_DATE("getdate()");
stressTestDataBean.setSTATE("A");
ifSucc = StressTestDataDao.addStressTestData(db,stressTestDataBean);
}else{
ifSucc = StressTestDataDao.mendStressTestData(db,stressTestDataBean);
}