Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

There are several different ways to copy arrays of object (primitive types) in Java. However, the fastest way seems to be System.arraycopy. This methed is implemented using native code and only performs a shallow copy. Acutally most methods for copying arrays in Java perform shallow copy.

int arr1[] = {0, 1, 2, 3, 4, 5};
int arr2[] = {0, 10, 20, 30, 40, 50};
// copies 3 elements from arr1 to arr2 
System.arraycopy(arr1, 0, arr2, 0, 3);