如何遍历一个二维数组:
代码:
package day007;
/**
*
* @author 左左
* @Date 2020-03-23 21:48:33
* @Description 如何遍历一个二维数组
* 如:int[][] arr = new int[][]{{1,2,3},{4,5},{6,7,8}};
*
*/
public class ArrayTest {
public static void main(String[] args) {
int[][] arr = new int[][]{{1,2,3},{4,5},{6,7,8}};
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
System.out.print(arr[i][j]+ "\t");
}
System.out.println();
}
}
}
测试结果: