// Scott DeRuiter 7/24/2002
// TwoDArray1.java
// First 2D array example
public class TwoDArray1
{
public static void main (String[] args)
{
int row = 7, col = 9;
int [][] table = new int[row + 1][col + 1];
for (row = 1; row <= 7; row++)
for (col = 1; col <= 9; col++)
table[row][col] = row * col;
System.out.println ( "\n\n" );
for (row = 1; row <= 7; row++)
{
for (col = 1; col <= 9; col++)
System.out.print ( Format.right ( table[row][col], 4 ) );
System.out.println ( );
}
System.out.println ( "\n\n" );
}
}
Back to Lesson 17 Examples
Back to Java Main Page