// create array using 1D arrays public class aoa0 { public static void main(String args[]) { // create 2x2 array: final int SIZE = 2; int[][] a = new int[SIZE][SIZE]; // create array $r0$ and store values 1 and 2: int[] r0 = new int[2]; r0[0] = 1; r0[1] = 2; // create array $r1$ and store values 3 and 4: int[] r1 = new int[2]; r1[0] = 3; r1[1] = 4; // store refs to arrays $r0$ and $r1$ as // 1st and 2nd elements of array $a$: a[0] = r0; a[1] = r1; // Use $a[i][j]$ to access elements: for ( int i=0 ; i < a.length ; i++) { // "rows" for ( int j = 0 ; j < a[i].length ; j++) // "cols" System.out.print(a[i][j] +" ") ; // element System.out.println(); // skip line between rows } } // method main } // class aoa0 /* Output 1 2 3 4 */