/********************************************************************* * Author: Eric Heim * Date Created: 6/21/2011 * Course: CS0007 * Description: Shows the creation and use of a two dimensional array *********************************************************************/ public class RaggedArray { public static void main(String[] args) { int[][] ragged = new int[4][]; int count = 1; ragged[0] = new int[3]; ragged[1] = new int[4]; ragged[2] = new int[5]; ragged[3] = new int[6]; for(int i = 0; i < ragged.length; i++) { for(int j = 0; j < ragged[i].length; j++) { ragged[i][j] = count; count++; } } System.out.println("The contents of the array is:"); for(int i = 0; i < ragged.length; i++) { for(int j = 0; j < ragged[i].length; j++) { System.out.print(ragged[i][j] + "\t"); } System.out.print('\n'); } } }