如何记录主方法的参数

时间:2021-10-04 16:34:35

How should I document the parameter of the following method?

我该如何记录以下方法的参数?

public static void main (String[] args) throws IOException

Should I use @param?

我应该使用@param吗?

2 个解决方案

#1


2  

Using JavaDoc...

使用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 on how JavaDoc comments work.

这是一个关于JavaDoc注释如何工作的文档。

#2


0  

Use javadoc, but in the case of arrays (including varargs), I prefer to describe each element's meaning, eg

使用javadoc,但在数组(包括varargs)的情况下,我更喜欢描述每个元素的含义,例如

/**
 * 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 {
  //
}

Although this is not "officially sanctioned" (AFAIK), it is much clearer.

虽然这不是“官方认可的”(AFAIK),但它更加清晰。

If this is a "main" method, documenting the exception is a bit pointless, as nothing will catch it.

如果这是一个“主要”方法,记录异常是有点无意义的,因为没有什么能够捕获它。

#1


2  

Using JavaDoc...

使用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 on how JavaDoc comments work.

这是一个关于JavaDoc注释如何工作的文档。

#2


0  

Use javadoc, but in the case of arrays (including varargs), I prefer to describe each element's meaning, eg

使用javadoc,但在数组(包括varargs)的情况下,我更喜欢描述每个元素的含义,例如

/**
 * 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 {
  //
}

Although this is not "officially sanctioned" (AFAIK), it is much clearer.

虽然这不是“官方认可的”(AFAIK),但它更加清晰。

If this is a "main" method, documenting the exception is a bit pointless, as nothing will catch it.

如果这是一个“主要”方法,记录异常是有点无意义的,因为没有什么能够捕获它。