Copying arrays/assigning the 'value' of the array to another.

  • Thread starter Thread starter Hiche
  • Start date Start date
  • Tags Tags
    Array Value
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
Hiche
Messages
82
Reaction score
0
Code:
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.
 
Physics news on Phys.org