java 在表中显示多维数组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 在表中显示多维数组相关的知识,希望对你有一定的参考价值。

 // Making multidimensional arrays
        int firstArray[][] = {{8, 9, 10, 11, 12}, {13, 14, 15, 16, 17}};
        int secondArray[][] = {{30, 31, 32, 33}, {43}, {4, 5, 6}};

        // Printing out the first array by calling it from the **TABLE** method
        System.out.println("This is the first array");
        table(firstArray);

        // Printing out the second array by calling it from the **TABLE** method
        System.out.println("This is the second array");
        table(secondArray);
    }


    // Making a new method and passing a multidimensional array in the parameters
    public static void table(int x[][]) {

        // First for loop: loops through the rows which is the firstArray[]
        for (int row = 0; row < x.length; row++) {

            // Second for loop: loops through the columns which is the secondArray[]
            for (int column = 0; column < x[row].length; column++) {

                // Printing the rows and the columns with spaces in between the values
                System.out.print(x[row][column] + "\t");
            }
            // Printing a new line whenever the values of the first part of the array end so it is displayed in a table formation
            System.out.println();

以上是关于java 在表中显示多维数组的主要内容,如果未能解决你的问题,请参考以下文章

使用语句在表中插入java字节数组

使用 ReactJS 显示多维数组

如何使用ng-repeat在表中显示数组

在表视图内的集合视图中传递多维数组

来自不同数组的不同值并在表中并排附加在一起

Vue(Laravel 8)无法正确呈现存储在表中的数组