//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author Casey Bowman * @version 1.1 * @date Mon Mar 02 13:22:55 EST 2015 * @see (License) MIT style license */ //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Simple program for retrieving command line arguments. * * e.g. > java CommandLineArguments Casey Bowman * * This program does not attempt to convert Strings to other data types. * You can see examples of conversions in the file ConvertingCommandLineArguments.java. */ public class CommandLineArguments { //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Main method. String[] args is a String array containing the command * line arguments you want to use in your program. This program also uses * the switch statement. * @see http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html */ public static void main (String[] args) throws Exception { int n = args.length; switch (n) { case 0: System.out.println ("You didn't enter any command line arguments!"); break; case 1: System.out.println ("You input the string <" + args[0] + ">"); break; case 2: System.out.println ("You input two strings: <" + args[0] + "> and <" + args[1] + ">"); break; default: System.out.println ("That's too many input arguments for me to handle!"); break; } // switch } // main } // CommandLineArguments