publicclassArryTest2{
publicstaticvoidmain(String[] args){
int[][] arr =newint[][]{
{
3,5,8},{
12,9},{
7,0,6,4}};int sum =0;for(int i =0;i < arr.length;i++){
//遍历arr数组for(int j =0;j < arr[i].length;j++){
//遍历arr[i]数组
sum += arr[i][j];}}System.out.println("总和为:"+ sum);}}
/*声明:int[] x,y[]; 在给x,y变量赋值以后,以下选项允许通过编译的是:
a) x[0] = y; no
b) y[0] = x; yes
c) y[0][0] = x; no
d) x[0][0] = y; no
e) y[0][0] = x[0]; yes
f) x = y; no
*/int[] x,y[];int[] x;int[] y[];
public class ArryTest2 { public static void main(String[] args) { int[][] arr = new int [][]{{3,5,8},{12,9},{7,0,6,4}}; int sum = 0; for(int i = 0;i < arr.length;i++){//遍历arr数组 for(int j = 0;j < arr[i].length;j++){//遍历arr[i]数组.