posts - 42, comments - 7, trackbacks - 0, articles - 1

          java代碼注釋風(fēng)格

          Posted on 2008-05-29 12:10 TuringJava 閱讀(785) 評(píng)論(0)  編輯  收藏 所屬分類: J2SE
          整個(gè)類文件注釋

          示例如下:
          Java代碼 
          1. /* 
          2.  
          3.  * @(#)Object.java     1.61 03/01/23 
          4.  
          5.  * 
          6.  
          7.  * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 
          8.  
          9.  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 
          10.  
          11.  */  
          12.   
          13.    
          14.   
          15. package java.lang;  



          注釋結(jié)構(gòu):
          Java代碼 
          1. /* 
          2.  
          3.  * @(#){類名稱}.java       {創(chuàng)建時(shí)間} 
          4.  
          5.  * 
          6.  
          7.  * {某人或某公司具有完全的版權(quán)} 
          8.  
          9.  * {使用者必須經(jīng)過許可} 
          10.  
          11.  */  
          12.   
          13.    
          14.   
          15. package java.lang;  
          16.   
          17.    




          2. 具體類功能注釋

          示例如下:
          Java代碼 
          1. /** 
          2.  
          3.  * Class <code>Object</code> is the root of the class hierarchy. 
          4.  
          5.  * Every class has <code>Object</code> as a superclass. All objects, 
          6.  
          7.  * including arrays, implement the methods of this class. 
          8.  
          9.  * 
          10.  
          11.  * @author  unascribed 
          12.  
          13.  * @version 1.61, 01/23/03 
          14.  
          15.  * @see     java.lang.Class 
          16.  
          17.  * @since   JDK1.0 
          18.  
          19.  */  
          20.   
          21. public class Object {}  
          22.   
          23.    


          注釋結(jié)構(gòu):
          Java代碼 
          1. /** 
          2.  
          3.  * 類 <code>{類名稱}</code>{此類功能描述} 
          4.  
          5.  * 
          6.  
          7.  * @author  {作者} 
          8.  
          9.  * @version {版本,常用時(shí)間代替} 
          10.  
          11.  * @see     java.lang.Class 
          12.  
          13.  * @since   JDK{jdk版本} 
          14.  
          15.  */  
          16.   
          17. public class Object {}  
          18.   
          19.    


          3. 類變量注釋

          示例如下:
          Java代碼 
          1. /** The value is used for character storage. */  
          2.   
          3.  private char value[];  
          4.   
          5.    

          注釋結(jié)構(gòu):
          Java代碼 
          1. /** {此值是用來存儲(chǔ)/記錄什么的}*/  
          2.   
          3. private String str ;  


          4. 類方法注釋

          示例如下:
          Java代碼 
          1.     /** 
          2.  
          3.      * Returns a new string that is a substring of this string. The 
          4.  
          5.      * substring begins with the character at the specified index and 
          6.  
          7.      * extends to the end of this string. <p> 
          8.  
          9.      * Examples: 
          10.  
          11.      * <blockquote><pre> 
          12.  
          13.      * "unhappy".substring(2) returns "happy" 
          14.  
          15.      * "Harbison".substring(3) returns "bison" 
          16.  
          17.      * "emptiness".substring(9) returns "" (an empty string) 
          18.  
          19.      * </pre></blockquote> 
          20.  
          21.      * 
          22.  
          23.      * @param      beginIndex   the beginning index, inclusive. 
          24.  
          25.      * @return     the specified substring. 
          26.  
          27.      * @exception  IndexOutOfBoundsException  if 
          28.  
          29.      *             <code>beginIndex</code> is negative or larger than the 
          30.  
          31.      *             length of this <code>String</code> object. 
          32.  
          33.      */  
          34.   
          35. public String substring(int beginIndex) {  
          36.   
          37. return substring(beginIndex, count);  
          38.   
          39. }  
          40.   
          41.    


          注釋結(jié)構(gòu):
          Java代碼 
          1.     /** 
          2.  
          3.      * {方法的功能/動(dòng)作描述} 
          4.  
          5.      * 
          6.  
          7.      * @param      {引入?yún)?shù)名}   {引入?yún)?shù)說明} 
          8.  
          9.      * @return      {返回參數(shù)名}   {返回參數(shù)說明} 
          10.  
          11.      * @exception   {說明在某情況下,將發(fā)生什么異常} 
          12.  
          13.      */  
          14.   
          15. public String substring(int beginIndex) {  
          16.   
          17. return substring(beginIndex, count);  
          18.   
          19. }  
          20.   
          21.    




          5. 類方法中代碼塊注釋

          示例如下:
          Java代碼 
          1. /* 
          2.  
          3. * 調(diào)用持久化類,將數(shù)據(jù)保存到庫 
          4.  
          5.  
          6. * 判斷是添加,還是修改 
          7.  
          8. */  
          9.   
          10. boolean ifSucc = false;  
          11.   
          12. if(request.getParameter("YINGLI_ID")==null){  
          13.   
          14.        String GUID = new RandomGUID().toString();  
          15.   
          16.        stressTestDataBean.setUSER_ID(Integer.toString(userId));  
          17.   
          18.        stressTestDataBean.setSIGN_ISBN((String)vSectNum.get(0));  
          19.   
          20.        stressTestDataBean.setSHENHE_JIEGUO("0");  
          21.   
          22.        stressTestDataBean.setGUID(GUID);  
          23.   
          24.        stressTestDataBean.setCREATE_DATE("getdate()");  
          25.   
          26.        stressTestDataBean.setSTATE("A");  
          27.   
          28.                                            
          29.   
          30.        ifSucc = StressTestDataDao.addStressTestData(db,stressTestDataBean);  
          31.   
          32. }else{  
          33.   
          34.        ifSucc = StressTestDataDao.mendStressTestData(db,stressTestDataBean);  
          35.   
          36. }  
          37.   
          38.    




          注釋結(jié)構(gòu):
          Java代碼 
          1. /* 
          2.  
          3. * {功能描述} 
          4.  
          5.  
          6. * {具體實(shí)現(xiàn)動(dòng)作} 
          7.  
          8. */  
          9.   
          10. boolean ifSucc = false;  
          11.   
          12. if(request.getParameter("YINGLI_ID")==null){  
          13.   
          14.        String GUID = new RandomGUID().toString();  
          15.   
          16.        stressTestDataBean.setUSER_ID(Integer.toString(userId));  
          17.   
          18.        stressTestDataBean.setSIGN_ISBN((String)vSectNum.get(0));  
          19.   
          20.        stressTestDataBean.setSHENHE_JIEGUO("0");  
          21.   
          22.        stressTestDataBean.setGUID(GUID);  
          23.   
          24.        stressTestDataBean.setCREATE_DATE("getdate()");  
          25.   
          26.        stressTestDataBean.setSTATE("A");  
          27.   
          28.                                            
          29.   
          30.        ifSucc = StressTestDataDao.addStressTestData(db,stressTestDataBean);  
          31.   
          32. }else{  
          33.   
          34.        ifSucc = StressTestDataDao.mendStressTestData(db,stressTestDataBean);  
          35.   

          主站蜘蛛池模板: 福泉市| 普兰店市| 斗六市| 冷水江市| 台东县| 久治县| 蛟河市| 织金县| 衡南县| 临邑县| 宿松县| 巴里| 依兰县| 巴林右旗| 高尔夫| 宁远县| 襄城县| 峨边| 长乐市| 新昌县| 民丰县| 莲花县| 田东县| 凤山市| 六安市| 岗巴县| 宁晋县| 郑州市| 楚雄市| 通州区| 海门市| 正阳县| 湛江市| 深州市| 香港| 东兰县| 临沂市| 三明市| 定州市| 台东市| 那坡县|