-3

How should I document the parameter of the following method?

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

Should I use @param?

Bohemian
  • 412,405
  • 93
  • 575
  • 722

2 Answers2

3

Using 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.

Todd
  • 30,472
  • 11
  • 81
  • 89
  • Props for understanding the question and providing an answer based on that... (It's way more than I got after reading the question) – blurfus Dec 29 '14 at 21:53
0

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

/**
 * 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.

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

Bohemian
  • 412,405
  • 93
  • 575
  • 722