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

  • Thread starter Hiche
  • Start date
  • #1
84
0

Main Question or Discussion Point

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
33,265
4,965
This should work. Try it out and see.
 

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

Replies
13
Views
921
  • Last Post
Replies
4
Views
579
Replies
4
Views
11K
Replies
3
Views
4K
  • Last Post
Replies
4
Views
2K
Replies
3
Views
3K
Replies
13
Views
1K
Top