Currently, Arrays.copyOf behaves similarly to manually allocating a new array followed by a call to System.arraycopy to populate it (partially or fully). Apart from being a more convenient abstraction, Arrays.copyOf generally offers no inherent performance advantages over this manual approach.
However, there is potential for optimization: the JVM could skip zero-initializing the portion of the array that will be immediately overwritten. This would, for example, improve the performance of ArrayList when it increases its internal capacity—a process that typically involves allocating a new array (usually 50% larger) and copying the old elements into the beginning of the new array. Currently, the entire new array is zero-initialized, including the region that will be promptly overwritten by the copy operation.
However, there is potential for optimization: the JVM could skip zero-initializing the portion of the array that will be immediately overwritten. This would, for example, improve the performance of ArrayList when it increases its internal capacity—a process that typically involves allocating a new array (usually 50% larger) and copying the old elements into the beginning of the new array. Currently, the entire new array is zero-initialized, including the region that will be promptly overwritten by the copy operation.