arraycopy(Obkect src,itn secPro, Object dest, int destPos,int length)

System類中的靜態方法

作用:複製當前數組指定長度到新數組中

arraycopy(Object src,itn secPro, Object dest, int destPos,int length)

參數說明:源數組,原數組複製起始位置,目標數組,目標數組粘貼起始位置,複製數組的長度

int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
int[] des = new int[6];
des[0] = 1;
des[1] = 3;
System.arraycopy(arr,0,des,2,4);
System.out.println(Arrays.toString(des));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章