CPSC 170 Lab 2
Searching, Sorting and 2-D Arrays

As usual, create a lab2 subdirectory for today's lab, open this document in Mozilla, and start emacs.

Command Line Arguments

As we discussed in class, when you run a Java program called Foo, anything typed on the command line after "java Foo" is passed to the main method in the args parameter as an array of strings.
  1. Write a program Command.java that just prints the strings that it is given at the command line, one per line. If nothing is given at the command line, print "No arguments".

  2. Modify your program so that it assumes that the arguments given at the command line are integers. If there are no arguments, print a "usage" message as we discussed in class. If there is at least one argument, compute and print the average of the arguments. Note that you will need to use the parseInt method of the Integer class to extract integer values from the strings that are passed in. If any of the values is not numeric, your program will produce an error, which is unavoidable at this point.
Print your program to turn in.

Searching and Sorting

File IntegerList.java contains a Java class representing a list of integers. Save this file to your directory, open it, and study it to be sure you understand it. The following public methods are provided: