ArrayAndArrayList

Work on this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.

Goals

The goals of this exercise are to apply and hence reinforce your understanding of:

Overview

You will checkout a program that reads integers from standard input and prints them in sorted order (smallest to largest). The version you checkout will use arrays. After examining and running the version that uses arrays, you will extend the program to do the same thing (read and sort) but using ArrayList instead of arrays. Also, you will use the extended for loop where appropriate.

    Stage 0 - Checkout the Project

  1. Open Eclipse.
  2. Checkout your ArrayAndArrayList project.
  3. Stage 1: Examine and run the version with an array

  4. Examine the code. Note especially: Run the program, providing about 5 inputs. Put some of the inputs on one line, some on another.
    Consider: If you enter non-numeric input, no error is given; the program simply treats the non-numeric input as signalling the end of the input. This is not a great user interface, but treat it as acceptable. The program does have an egregious error, however. What inputs (hint: or number of inputs) can you supply to make that egregious error occur?
  5. Stage 2: Implement a version that uses ArrayList

  6. Write a static void method called GetSortAndPrintAnArrayList that: Comment out the call in main to GetSortAndPrintAnArray, add a call in main to GetSortAndPrintAnArrayList, and test your work.
    Consider: List the two major advantages of an ArrayList over an array.
    Consider: Which is generally preferable: using an ArrayList or using an array?
  7. Stage 3: Experience the debugger in Eclipse

  8. Experience the debugger in Eclipse by doing all of the following:
    1. Set breakpoints (before and after the sort)
    2. Run in debug mode
    3. Examine the variables at the first breakpoint.
    4. Continue to the next breakpoint.
    5. Examine the variables at the second breakpoint. Note yellow-highlighted.
    6. Disable and (eventually) remove all breakpoints
  9. Stage last: Turn in your work (i.e., commit your project)

  10. Make sure that your project has correct style. Make sure that there is appropriate HTML documentation.
  11. Commit your ArrayAndArrayList project to the repository from which you checked it out.