[course05] 02 Two-dimen
Declare and initialize
int[][] A;
A = new int[3][4];
int[][] A = { { 1, 0, 12, -1 },
{ 7, -3, 2, 5 },
{ -5, -2, 2, -9 }
};
A = new int[][] { { 1, 0, 12, -1 },
{ 7, -3, 2, 5 },
{ -5, -2, 2, -9 }
};The truth about 2D arrays
Java does not actually have two-dimensional arrays. In a true 2D array, all the elements of the array occupy a continuous block of memory, but that's not true in Java.
a 2D array is really an array of pointers, where each pointer can refer to a one-dimensional array.


Last updated
Was this helpful?