Two-dimensional arrays

A one-dimensional array can be seen as data elements organised in a row. A two-dimensional array is similar to a one-dimensional array, but it can be visualised as a grid (or table) with rows and columns.

For example, a nine-by-nine grid could be referenced with numbers for each row and letters for each column. A nine-by-nine, two-dimensional array could be declared with a statement such as:

game [9][9]

Many games use two dimensional arrays to plot the visual environment of a game. Positions in a two dimensional array are referenced like a map using horizontal and vertical reference numbers. They are sometimes called matrices.

We are not limited to making one and two-dimensional arrays. We can also make three-dimensional arrays as well. Many games (such as Minecraft) use three-dimensional arrays to model an environment.