Input using command line arguments
The following is copied from /users/ernie/321/commandLineInput.java
class commandLineInput{
public static void main (String[] args) {
int i;
int j;System.out.println( args.length );
for (i = 0; i < args.length; i++) {
j = Integer.parseInt( args[i] );
System.out.println( j );
}}
}From a program by Bret Curtis, modified by Ackermann in /users/ernie/public_html/321/numProbes.java on paprika.umw.edu
public static void main( String[] args)
{
if (args.length == 0)
{
throw new IllegalArgumentException("Please pass a number as an argument.") ;
}
else
{
int number = Integer.parseInt(args[0]);System.out.println("Array size of " + number + " can take up to " + manPro
bes(number) + " iterations ");
Input using standard in or files
The package EasyReader, available from the supplemental materials for the required text, provides support for input from standard in and files.
Here's a snippet of code from the application BagDemonstration that imports the package EasyReader and gets integers froom standard in.
int userInput; // An age from the user's family
System.out.println("Type the ages of your family members.");
System.out.println("Type a negative number at the end and press return.");
userInput = stdin.intInput( );
while (userInput >= 0) {
ages.add(userInput);
userInput = stdin.intInput( );
}

.