//  Scott DeRuiter     7/24/2002
//  TwoDArray2.java
//  Second 2D array example

public class TwoDArray2   
{
	int [][] table1 = { {0,0,0,0},
                  	    {0,0,0,0},
                  	    {0,0,0,0} };

	int [][] table2 = { {0,1,2,3,8},
                 	    {4,5,6,7,7,5,6},
                 	    {8,9,10,11,35} };

	public static void main (String[] args)   
	{

		TwoDArray2 thisprog = new TwoDArray2();
		thisprog.RunIt ( );
	}

	public void RunIt ( )   
	{
		System.out.println ( "\n\n" );

		Printout ( table1 );

		System.out.println ( "\n\n" );

		Printout ( table2 );

		System.out.println ( "\n\n" );
	}

	public void Printout ( int [][] table )   
	{
		for (int row = 0; row < table.length; row++)   
		{
			for (int col = 0; col < table[row].length; col++)
				System.out.print ( Format.right ( table[row][col], 4 ) );
			System.out.println ( );
		}
	}
}

Back to Lesson 17 Examples

Back to Java Main Page