Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2007/ia/paper-5/9/a/solution

A Java array can hold references to row arrays. For example,
double[][] grid = new double[rows][columns];
grid[2][3] = 4.5;
allocates the outer array and all equal-length rows, with numeric entries initially zero. A ragged alternative is
double[][] grid = new double[rows][];
for (int r = 0; r < rows; r++)
    grid[r] = new double[r + 1];
The second form initially has null row references, so each row must be allocated before access. Rows need not have equal lengths, and a two-dimensional array of objects initially contains null object references rather than constructed cell objects. Java represents a two-dimensional array as an array of arrays.

New to topics? Read the docs here!