I want to duplicate an array. Typically, I would just do something like this.
int[] a1 = {1, 2, 3};
int[] a2 = a1
Recently however, I saw my professor do it this way:
int[] ar1 = {1, 2, 3};
int[] ar2 = Arrays.copyOf(ar1);
Is there an advantage between doing it one way over the other? What is the main difference?