<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// Warning: you might find this one tough...
// pg 228: How does a multidimensional array really 
// get stored? as a 1D array of other arrays.
// What in the world does that mean? 
// Check this out....

public class array_of_arrays {
    public static void main(String args[]) {

	// create an array of arrays
	// each element of A will be an array
	int[][] A = new int[2][2];
	
	// create array a0 and store values
	int[] a0 = new int[2];
	a0[0] = 11;
	a0[1] = 12;

	// create array a1 and store values
	int[] a1 = new int[2];
	a1[0] = 21;
	a1[1] = 22;
	
	// store arrays a0 and a1 as 1st and 2nd
	// elements of array A
	// Array A now stores 1D arrays as each element:
	A[0] = a0;
	A[1] = a1;

	// How do you access such a beast?
	// Use A[i][j] 
	// The "i" refers to the elements of A
	// The "j" refers to elements of the elements of A
	System.out.println();
	for (int i = 0; i &lt;= 1; i++) {
	    for (int j = 0; j &lt;= 1; j++)
		System.out.print(A[i][j] + " ");
	    System.out.println();
	}

    } // method main

} // class array_of_arrays

/* Output

11 12 
21 22 
*/
</pre></body></html>