【发布时间】:2015-02-26 02:12:32
【问题描述】:
我应该如何记录下面方法的参数?
public static void main (String[] args) throws IOException
我应该使用@param吗?
【问题讨论】:
我应该如何记录下面方法的参数?
public static void main (String[] args) throws IOException
我应该使用@param吗?
【问题讨论】:
使用 JavaDoc...
/**
* Our main method. Some kind of handy description goes here.
* @param args The command line arguments.
* @throws java.io.IOException when we can't read a file or something like that.
**/
public static void main(String[] args) throws IOException {
...
}
Here is a document 了解 JavaDoc cmets 的工作原理。
【讨论】:
使用javadoc,但对于数组(包括可变参数),我更喜欢描述每个元素的含义,例如
/**
* Copies a file
* @param args[0] The source file path
* @param args[1] The target file path
* @throws IOException if an error occurs
**/
public static void main(String[] args) throws IOException {
//
}
虽然这不是“官方认可的”(AFAIK),但要清楚得多。
如果这是一个“主要”方法,那么记录异常有点毫无意义,因为没有任何东西可以捕捉到它。
【讨论】: