/*
二维数组:数组中的每个数组元素又是一维数组。
多维数组不必要是规则矩阵
*/
public class TwoArray{
public static void main(String[] args){
int[] array1 = new int[5];
//定义二维数组
int[][] array2 = new int[3][];
//定义二维数组中的每个一维数组的大小
array2[0] = new int[2];
array2[1] = new int[4];
array2[2] = new int[3];
//为一维数组中的每个元素赋值
array2[0][0] = 1;
array2[0][1] = 2;
array2[1][0] = 10;
array2[1][1] = 20;
array2[1][2] = 30;
array2[1][3] = 40;
array2[2][0] = 100;
array2[2][1] = 200;
array2[2][2] = 300;
//输出二维数组的每个值
for(int i = 0; i <array2.length;i++){
for(int j = 0; j <array2[i].length; j++ ){
System.out.print(array2[i][j] + "\t");
}
}
//数组的拷贝
/*String[] s = {"Mircosoft","IBM","Sun","Oracle","Apple"};
String[] sBak = new String[6];
System.arraycopy(s,0,sBak,0,s.length);
for(int i=0;i<sBak.length;i++){
System.out.print(sBak[i]+" ");
}*/
/*System.out.println();
int[][] intArray = {{1,2},{1,2,3},{3,4}};
int[][] intArrayBak = new int[3][];
System.arraycopy(intArray,0,intArrayBak,0,intArray.length);
intArrayBak[2][1] = 100;
for(int i = 0;i<intArrayBak.length;i++){
for(int j =0;j<intArrayBak[i].length;j++){
System.out.print(intArrayBak[i][j]+" ");
}
System.out.println();
}*/
}
}