Quantcast
Channel: What is more efficient: System.arraycopy or Arrays.copyOf? - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by matsev for What is more efficient: System.arraycopy or Arrays.copyOf?

$
0
0

Have you looked at the Sun's implementation of Arrays.copyOf()?

 public static int[] copyOf(int[] original, int newLength) {
    int[] copy = new int[newLength];
    System.arraycopy(original, 0, copy, 0,
                     Math.min(original.length, newLength));
    return copy;
}

As can be seen, it uses System.arraycopy() internally, so the performance would be the same.


Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>