In main method:
- If number of parameters > 2, then a print usage is displayed.
if (args.length != 2) usage();
- However, if number of parameters == 2, then a null pointer is thrown
if (args[2].equals("once")) { return; }
Consequences:
- third parameter ("once") cannot be used
- An error will always be thrown
Here is a proposed modified main method:
-When checking presence of "once" third parameter
if (thirdArgumentExpectedValue.equals(args[2])) {
return;
}
In main method:
if (args.length != 2) usage();if (args[2].equals("once")) { return; }Consequences:
Here is a proposed modified main method:
When checking if arguments are well formated:
-When checking presence of "once" third parameter