// finding length of each dimension in an array

public class array_length {
    
    public static void main(String args[]) {
	
	// declare array
	// you *may* use initializer list
	// note how there are 3 rows and 2 cols

	int [][] a = { {1, 2}, {3, 4}, {5, 6} };
	// think of this initializer lists as
	// { row1, row2, row3 }
	// where each row# means
	// { col1, col2 }
	
	// rows: find the length of the "outer" array
	// that contains arrays in each element
	int r = a.length;

	// cols: find the length of any of the elements
	// which are all arrays of the same length
	int c = a[0].length;
	
	System.out.println("Rows: " + r);
	System.out.println("Cols: " + c);
	System.out.println("Here is your table:\n");

	for (int i = 0; i <= r-1; i++) {
	    for (int j = 0; j <= c-1; j++)
		System.out.print(a[i][j] + " ");
	    System.out.println();
	}
	
    } // method main

} // class array_length

/*
Rows: 3
Cols: 2
Here is your table:

1 2 
3 4 
5 6 
*/
