我正在使用 Java 中的数组并有这个疑问。java中如何求二维数组的维数?例如,我从 System.in 获取数组输入并将其传递到另一个方法中,如下所示:
Scanner in = new Scanner(System.in);
int arr[][] = new int[6][6];
for(int i=0; i < 6; i++){
for(int j=0; j < 6; j++){
arr[i][j] = in.nextInt();
}
}
findSize(arr);
/*
*
*Other code
*
*/
findSize(int[] inputArr){
//I want to find the dimensions of the array here
}
Run Code Online (Sandbox Code Playgroud)
数组的两个维度都大于 0。感谢您的帮助。