Determine the number of rows and columns of a 2D array

foreword

When the parameter type of the method is two-dimensional array type int[][] array, how to determine the function and number of columns of the array array in the method.

experimental code

public class Main {
    public static void main(String[] args){
        int[][] array = new int[4][3];
        System.out.print(array.length);
        System.out.print(array[0].length);
    }
}

Output: 43

Conclusion: array.length: the number of rows of a two-dimensional array
   array[0].length: the number of columns of a two-dimensional array

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325580326&siteId=291194637
Recommended