CSSE 221: Fundamentals of Software Development Honors
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.

Stage 1: Examine and run the version with an array

  1. 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?

Stage 2: Implement a version that uses ArrayList

  1. 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?

Stage 3: Experience the debugger in Eclipse

  1. 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

Stage last: Turn in your work (i.e., commit your project)

  1. Make sure that your project has correct style. Make sure that there are appropriate Javadoc comments.
  2. Commit your ArrayAndArrayList project to the repository from which you checked it out.