1.编写一个程序用分别用for循环和foreach输出二维数组int a[][] ={{3,2,4,5},{1,2,3,4},{3,3,2,1,}}的值
1 回答
蜂之谷
TA贡献564条经验 获得超863个赞
int a[][] ={{3,2,4,5},{1,2,3,4},{3,3,2,1,}}; //for for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.print(a[i][j]+" "); } System.out.println(); } System.out.println("-------------------------------"); //foreach for (int[] is : a) { for (int i : is) { System.out.print(i+" "); } System.out.println(); }
添加回答
举报
0/150
提交
取消