2012-11-16 64 views
0

是否正確的java文檔方法文檔? 我的部分代碼如下。沒有參數但有回報。只有局部變量。是否正確的java文檔方法文檔?

/** 
*This method prompts user to enter the how many numbers user is going to test. 
* 
*@return  The validated value based on parameter. 
*/ 

public static int getNum() 
{ 
    int t; 
    Scanner input=new Scanner(System.in); 

    System.out.print("How many numbers would you like to test? "); 
    t=input.nextInt(); 

    while (validateNum(t)) 
    { 
     System.out.print("How many numbers would you like to test? "); 
     t=input.nextInt(); 
    } 

    return t; 
} 

回答

0

Javadoc文檔的方法應該開始的話「這種方法」 - 這是在每一個方法的描述開始暗示

同樣,當記錄類別時,假定單詞「This class」出現在您的評論之前。另外,你正在描述實現(詢問用戶),但實現應該可以自由地以任何方式得到它,例如從文件中讀取它或返回一個常量。

這裏的東西更適合:

/** 
* Return how many numbers user is going to test. 
* 
* @return The number of numbers to be tested 
*/