javac CLA.java java CLA a s this 1the command line arguments would be "a s this 1"
public static void main(String[] args)the "args" variable is there to hold the command line arguments.
Inside you main method write a loop to print all of the command line arguments (values and indices). For instance, in the example above, your program might should output
0 a 1 s 2 this 3 1Make sure the output of your program agrees with this sample. Also try your program with other command line arguments. (Note, to get command line arguments you will need to compile and run your java program from the command line, you cannot use the handy "run" button in VSC.)
The idea is to create an array of strings that the program will use if there are no command line arguments. That array would look exactly like the command line args. For instance (keeping with the example above),
String[] myDefaults = {"a", "s", "this", "1"};Then use this array of default arguments when the program starts with no arguments from the command line. For example, by adding the following code neat the top of your main method
if (args.length = 0) { args = myDefaults; }
Extend the main method of CLA to have a set of default arguments and use them when no command line arguments are provided.
Future assignments will use command line arguments. The technique implemented in this lab should make your debugging and development easier.