📜  如何在java代码示例中获取二维数组的维度

📅  最后修改于: 2022-03-11 14:52:30.888000             🧑  作者: Mango

代码示例3
public static void main(String[] args) {

    int[][] foo = new int[][] {
        new int[] { 1, 2, 3 },
        new int[] { 1, 2, 3, 4},
    };

    System.out.println(foo.length); //2 // gives count of rows
    System.out.println(foo[0].length); //3 // gives count of columns for particular row
    System.out.println(foo[1].length); //4
}