<span style="font-size:14px;">public class TestArrayCopy {
public static void main(String[] args) {
String[] s = {"Microsoft", "IBM", "Cisco", "Oracle",
"Google", "Apple", "Intel", "Qualcomm"};
String[] sBak = new String[10];
/*
for(int i=0; i<sBak.length; i++) { //输出全为null
System.out.println(sBak[i] + " ");
}
*/
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<intArray.length; i++) {
for(int j=0; j<intArray[i].length; j++) {
System.out.print(intArray[i][j] + " ");
}
System.out.println();
}
}
}</span>
<span style="font-size:14px;">/**************输出结果(注意最后两个是null):
Microsoft IBM Cisco Oracle Google Apple Intel Qualcomm null null
1 2
1 2 3
3 100
****************/</span>
to be continued ...