System.arraycopyの中でのJavaの使用法を理解するための3分

このシステムは、我々は、アレイ間のレプリケーションを実装するために使用することができます)(静的メソッドのarraycopyを提供します。その関数のプロトタイプは次のとおりです。

public static native void arraycopy(Object src,int srcPos,Object dest, int destPos,int length);
* @param      src      the source array. 源数组
* @param      srcPos   starting position in the source array. 源数组的起始位置
* @param      dest     the destination array. 目标数组
* @param      destPos  starting position in the destination data. 目标数组的起始位置
* @param      length   the number of array elements to be copied. 复制的长度

栗の場合:

新しい配列にコピーされた配列array;

int[] array = {1, 2, 3, 4, 5};
int[] targetArr = new int[array.length];
System.arraycopy(array,0,targetArr,0,array.length);

おすすめ

転載: www.cnblogs.com/benjieqiang/p/11428832.html
おすすめ