An index is used to point at a data element within an array .
The gameScores array mentioned on page 2 has five data elements:
gameScores = (124, 99, 121, 105, 132)
Each element can be referenced according to its position in the array, starting at zero (0).
To refer to the first element in the gameScores array, we would need to ask for index zero in gameScores. This would be written as:
This would return the element 124.
The indexes continue corresponding to the positions of the subsequent data elements. The element at index 1 – gameScores - is 99 and at index 2 – gameScores - is 121.
Indexes are also used to change an element. For example, the first gameScores element could be changed to 95 with the statement:
The gameScores array would now contain the elements 95, 99, 121, 105, 132.