Arrays

An array is a grouping of two or more variables of the same type. Values are stored at the indexed locations in the list.

A list of movies you'd like to see is an example of a one dimensional array

Index Value
1. Moulin Rouge!
2. Romeo + Juliet
3. Strictly Ballroom

For a one dimensional array, you only need one index value for each unique location. The value stored at location 3 is "Strictly Ballroom".

The multiplication table is an example of a two dimensional array.

  1 2 3
1 1 2 3
2 2 4 6
3 6 8 9

For a two dimensional array, you need two index values for each unique location. The value stored at location row 2 column 3 is 6.

Declaring an array depends on the programming language:

Visual Basic Family Dim SongList(5) As String Creates an array with 6 elements indexed from 0 to 5.
Java String songList[] = new String[5];
String songList[] = {comma-separated list of elements};
Creates an array of 5 elements indexed from 0 to 4.
JavaScript var songList = new Array(5);
var songList = new Array(comma-separated list of elements);
Creates an array of 5 elements indexed from 0 to 4.

Resizing an array depends on the programming language:

Visual Basic Family Dim SongList() As String

Redim SongList(5)
Redim Preserve SongList(5)

Java Can't be done.
JavaScript var songList = new Array(5);

songList[10] = "Your Song";