Reputation: 809
I am creating a Jdoc comment above main method.
What would be the right description for args in this case?
/**
* supplies command-line arguments as an array of String objects
* @param args
*/
public static void main (String args[]) {
Apple apple = new Apple();
String firstInput = JOptionPane.showInputDialog("Enter number of apples: ");
apple.setNumber(Double.parseDouble(firstInput));
String secondInput = JOptionPane.showInputDialog("Enter apple type: ");
apple.setType(Double.parseDouble(secondInput));
JOptionPane.showMessageDialog(null, apple.toString());
}
Thanks a lot for checking out my question.
Upvotes: 1
Views: 5483
Reputation: 8387
What do you think about this comment:
/**
* The main method is where the Apple are created.
* @param args supplies command-line arguments as an array of String objects
*/
public static void main (String args[]) {
Upvotes: 0
Reputation: 3646
The main application entry point generally does not need documentation because it is a common, well understood method for Java applications. Even Oracle's "Hello World" example doesn't bother to document it.
But, if you still feel inclined to document the main method signature, perhaps something like the following would suffice:
/**
* The application's entry point
*
* @param args an array of command-line arguments for the application
*/
public static void main(String[] args) {
...
}
Remember that the intended target audience for Javadocs is developers and not your application users. As such, it makes little sense to document the exact details of the arguments in the Javadocs. Instead, consider printing out messages to the user if they passed an incorrect or missing argument. For a more comprehensive solution, you may also consider a library such as Apache Commons CLI.
Upvotes: 1