参考链接:

System提供了一个静态方法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); was 

END

相关文章:

  • 2022-12-23
  • 2021-12-29
  • 2021-10-11
  • 2021-09-17
  • 2021-06-24
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2022-01-03
相关资源
相似解决方案