FileDocCategorySizeDatePackage
ArrayOfArraysDemo2.javaAPI DocExample565Tue Dec 12 18:58:06 GMT 2000None

ArrayOfArraysDemo2

public class ArrayOfArraysDemo2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        int[][] aMatrix = new int[4][];

	//populate matrix
        for (int i = 0; i < aMatrix.length; i++) {
	    aMatrix[i] = new int[5];	//create sub-array
	    for (int j = 0; j < aMatrix[i].length; j++) {
	        aMatrix[i][j] = i + j;
	    }
        }

        //print matrix
        for (int i = 0; i < aMatrix.length; i++) {
	    for (int j = 0; j < aMatrix[i].length; j++) {
	        System.out.print(aMatrix[i][j] + " ");
	    }
	    System.out.println();
        }