二位数组的定义:
举例
int [][] = new int[2][3];
如上所示语句定义了一个2行3列的二位数组
二维数组的遍历:
for (int row = 0;row < 2;row++) {
for (int col=0;col < 3;col++) {
System.out.println(arr1[row][col]);
}
}
如上所示,二位数组的遍历需要使用双重循环
举例
int [][] = new int[2][3];
如上所示语句定义了一个2行3列的二位数组
for (int row = 0;row < 2;row++) {
for (int col=0;col < 3;col++) {
System.out.println(arr1[row][col]);
}
}
如上所示,二位数组的遍历需要使用双重循环