將數組a的前5個複製到b,將a1的後4個複製到b,組合成新數組b:
-------------------------------------------------------------------------------------------------------------------
int[] a = {2,2,2,2,2,0,0,0,0};
int[] a1 = {0,0,0,0,0,1,1,1,1};int[] b=new int[9];
//參數:數組源,拷貝的起始下標,目標數組,填寫的起始下標,拷貝的長度)
System.arraycopy(a, 0, b, 0, 5);
System.arraycopy(a1, 5, b, 5, 4);
for(int i=0;i<b.length;i++){
System.out.print(b[i]);
}
-------------------------------------------------------------------------------------------------------------------
輸出:222221111