苏州网站建设制作设计,开发公司更换物业公司的请示,360站长平台链接提交,厦门旅游网页设计java二维数组的遍历
/*
* java二维数组的遍历
* 二维数组#xff0c;数组座位数组元素类型的数组#xff0c;数组的数组
* */
public class Test14 {public static void main(String[] args) {int[][] arr {{1,2,3},{4,5},{6,7,8,9}};//从arr中取出每个元素//for循环遍历fo…java二维数组的遍历
/*
* java二维数组的遍历
* 二维数组数组座位数组元素类型的数组数组的数组
* */
public class Test14 {public static void main(String[] args) {int[][] arr {{1,2,3},{4,5},{6,7,8,9}};//从arr中取出每个元素//for循环遍历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();}//用foreach遍历for (int[] x:arr){for (int i:x){System.out.print(i\t);}System.out.println();}}
}执行代码如下