// see array_length2 -> how do you assign arrays of
// arrays with different lengths?

public class array_length3 {
    
    public static void main(String args[]) {
	
	// Declare array
	// You *may* use initializer list
	// Note how the columns may have different numbers
	// of elements (see pg 229)
	// From array_length2.java:
	// int [][] a = { {1, 2}, {3, 4, 5}, {6} };

	// instead of the initializer list,
	// you can also make the following declarations
	
	// full array
	int [][] a = new int[3][]; // a has 3 rows and varying # of columns

	// Row 1
	a[0] = new int[2];
	a[0][0] = 1;
	a[0][1] = 2;
	// could also say a[0] = {1,2}

	// Row 2
	a[1] = new int[3];
	a[1][0] = 3;
	a[1][1] = 4;
	a[1][2] = 5;
	// could also say a[1] = {3,4,5}

	// Row 3
	a[2] = new int[1];
	a[2][0] = 6;
	// could also say a[2] = {6}
	
	System.out.println("Here is your table:\n");

	// Loop over each row
	// So, use a.length for the number of rows
	// Don't forget to say N-1 for iteration!
	for (int i = 0; i <= a.length-1; i++) {

	    // Loop over each column
	    // NOTE: each column has a different length!
	    // Now, you really need to use the "array of arrays"
	    // concept: each element of array a is another array
	    // with different lenth...so use a[row].length

	    for (int j = 0; j <= (a[i].length)-1; j++)

		System.out.print(a[i][j] + " ");

	    System.out.println();
	}
	
    } // method main

} // class array_length2

/*
Here is your table:

1 2 
3 4 5 
6 
*/
