PDA

View Full Version : Copying arrays/assigning the 'value' of the array to another.


Hiche
Nov22-11, 12:54 PM
int[] aCopy = new int[a.length];
for (int i = 0; i < a.length; i++)
aCopy[i] = a[i];

Is this the way to 'copy' an array? Basically, I want the elements inside the the array a to be copied or assigned to the array aCopy.

Mark44
Nov22-11, 01:16 PM
This should work. Try it out and see.