What is the correct way to copy an array in Java?

Last Updated :
Discuss
Comments

What is the correct way to copy an array in Java?

arr2 = arr1;

arr2 = Arrays.copyOf(arr1, arr1.length);

arr2.clone(arr1);

Arrays.copy(arr1, arr2);

Share your thoughts in the comments