A Java array can hold references to row arrays. For example,allocates the outer array and all equal-length rows, with numeric entries initially zero. A ragged alternative isThe 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.
double[][] grid = new double[rows][columns];
grid[2][3] = 4.5;double[][] grid = new double[rows][];
for (int r = 0; r < rows; r++)
grid[r] = new double[r + 1]; Articles by others on the same topic
There are currently no matching articles.