Parallel Arrays

icon picker
parallel arrays

Parallel arrays are used to store a table of values with two more more headings.
One array is used for each column, the data type of each array must match the type of the values in the column.
Every array will have the same number of elements (rows).
Each array will have its own name which usually describes the values.

For example two parallel arrays could be used to store the names of the 4 seasons and the number of days in each season.
The season name array will be a String array for storing text.
The days array will be an integer array.
A row from the table uses values from different arrays but the same position in each array (parallel arrays).
To display the information for the first season:
display season[0] + days[0]

Visualising parallel arrays in BlueJ java

Loading…

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.