Is there any reason to prefer System.arraycopy() over clone()?

后端 未结 5 1930
深忆病人
深忆病人 2020-12-04 18:23

When copying an entire array, I\'ve often seen people write:

int[] dest = new int[orig.length];
System.arraycopy(orig, 0, dest, 0, orig.length);
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 18:31

    No. If you're really microbenchmarking, then maybe, depending on what JVM you're running. But in actuality, no.

提交回复
热议问题