public class ArrayCopyTest { private static final int SIZE_OF_ARRAY = 10000000; private static long time; public static void main(String[] args) { Integer [] sourceArray = new Integer[SIZE_OF_ARRAY]; Integer [] destinationArray = new Integer[SIZE_OF_ARRAY]; fillArray(sourceArray); startBenchmark(); naiveCopy(sourceArray,destinationArray); stopBenchmark(); startBenchmark(); System.arraycopy(sourceArray, 0, destinationArray, 0, sourceArray.length); stopBenchmark(); } private static void naiveCopy(Integer [] src, Integer [] dst) { for (int i = 0; i < src.length; i++) { dst[i]=src[i]; } } private static void fillArray(Integer [] src) { for (int i = 0; i < src.length; i++) { src[i]=i; } } private static void startBenchmark() { time = System.currentTimeMillis(); } private static void stopBenchmark() { time = System.currentTimeMillis() - time; System.out.println( "time="+time); } }