/* Author : Michael Robinson Program : array2dimensions.java Purpose : To present a two dimension array of int data type Updated : Jan 29, 2099 */ public class array2dimensions { public static void process2dArray( int numbers2d[][], int row, int col, int x, int y ) { //Load two dimensional array with each location's row+col System.out.println( "\nLoading two dimensional array" ); for( x = 0; x < row; x++ ) //process rows { for( y = 0; y < col; y++ ) //process columns { numbers2d[x][y] = x+y; //load up array with data } } //Display the contents of the two dimensional array System.out.println( " \nTwo dimensional array contents" ); for( x = 0; x < row; x++ ) //process rows { for( y = 0; y < col; y++ ) //process columns { if( (x+y) < col ) //test for variable width { System.out.print( " " ); //display space } //display data inside each array index System.out.print( " " + numbers2d[x][y] ); } System.out.println(); //display a line feed } }//end public static void process( int numbers2d ) public static void main( String arg[] ) { //Declare and initialize local variables //you can create multiple variables of the same type on //the same line int row = 20, col = 20; int x = 0, y = 0; //declares a 10x10 two dimensional array int numbers2d[][] = new int[ row ][ col ]; process2dArray( numbers2d, row, col, x, y ); }//end public static void main( String arg[] ) }//end public class array2dimensions