/***************************************************************************** * DESCRIPTION: * * This program shows how to obtain command line arguments typed in on * * the command line when running a Java program. The program simply prints * * out the command line arguents "as is" (i.e. as Strings). This program * * expects EIGHT command line arguments (i.e. you MUST type eight arguments). * * * * Note#1: The first argument is referenced as 0, the second as 1, etc. * * * * Note#2: When a program expects, for example, 5 command line arguments, * * if you type FEWER than 5 arguments then the program will bomb. * ****************************************************************************** * PROGRAM INPUT/OUTPUT: * * Program input is standard (keyboard) input. * * Program output is standard (screen) output. * *****************************************************************************/ public class Args { public static void main(String[] args) { // Print out the first two command line arguments, one per line System.out.println(); System.out.println("Argument#1: " + args[0]); System.out.println("Argument#2: " + args[1]); // Print the third & fourth arguments one per line in reversed order System.out.println(); System.out.println("Argument#4: " + args[3]); System.out.println("Argument#3: " + args[2]); // Print the fifth & sixth arguments side by side on one line System.out.println(); System.out.println("Argument#5 & #6: " + args[4] + " " + args[5]); // Print the seventh & eighth arguments one per line System.out.println(); System.out.println("Argument#7: " + args[6]); System.out.println("Argument#8: " + args[7]); } // EndMain } // EndClass Args