Martes, Pebrero 7, 2012

basic 34: table for multidimensional array

package basic;




public class Basic {




    public static void main(String[] args) {
        int array1[][] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
        int array2[][] = {{11, 12, 13, 14, 15}, {16, 17, 18,}};
        System.out.println("this is th 1st array");
        display(array1);
        System.out.println("this is the 2nd array");
        display(array2);




    }




    public static void display(int x[][]) {
        for (int row = 0; row < x.length; row++) {
            for (int column = 0; column < x[row].length; column++) {
                System.out.print(x[row][column] + "\t ");
            }
            System.out.println("");
        }
    }
}

Walang komento:

Mag-post ng isang Komento