标签:
public
class Array2Demo {
public static void main(String[] args){
int[][] arr = new int [3][4];
arr[1][2] = 78;
int[][] arr1 = new int[3][];
arr1[0] =new int[3];
arr1[1] = new int[1];
arr1[2] = new int [2];
arr1[0][2] = 90;
arr1[1][0] = 80;
arr1[2][1] = 70;
int[][] arr2 = {{1,2,3,4},{5,6},{7,7},{8,9}};
int sum=0;
for(int x=0; x<arr2.length; x++){
for(int y=0; y<arr2[x].length ; y++){
sum +=arr2[x][y];
}
}
//System.out.println("sum =" + " " + sum);
// System.out.println(arr);
// System.out.println(arr[0]);
// System.out.println(arr[0][0]);
// System.out.println(arr[1][2]);
//
// System.out.println(arr1);
// System.out.println(arr1[0]);
// System.out.println(arr1[0][2]);
// System.out.println(arr1[1][0]);
// System.out.println(arr1[2][1]);
//
// System.out.println(arr2);
// System.out.println(arr2[0]);
// System.out.println(arr2[0][3]);
//
// System.out.println(arr2.length);
// System.out.println(arr2[1].length);
}
}
标签:
原文地址:http://www.cnblogs.com/mabel/p/5899700.html