Pre-lab:
What is an Array?
An
Array is a data structure in which a collection of data items of the same type
can be stored. For instance, the student’s exam scores of a class can be
stored in an array of type integer. By using an array we can associate a single
variable name such as scores
with the entire collection of data. This association enables us to save the
entire collection of data in main memory and to reference individual items
easily.
In
Java, the array scores can be
represented as follows. The array below contains an index list of values with
each value has a numeric index. An array of size N is indexed from 0 to N – 1.
The following array of integers has a size of 10 and is indexed from 0 to 9.