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

  • Thread starter Hiche
  • Start date
  • #1
84
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.
 

Answers and Replies

  • #2
34,822
6,567
This should work. Try it out and see.
 

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

Replies
13
Views
1K
  • Last Post
Replies
4
Views
728
Replies
4
Views
12K
Replies
3
Views
4K
  • Last Post
Replies
4
Views
2K
Replies
3
Views
3K
Replies
13
Views
1K
Top