0

Hi, I need some enlightenment with copying arrays in JAVA from some of ya seasoned lots.

I have this 2d array , twoDarray[10][6] and another 1d array oneDarray[1,2,3,4,5,6]. I'd like to copy the 1d array into the 4th row of the 2d array.Suggestion please. Thnx in advance.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by RabbitruN
0

The twoDArray in your case is just an array of size 10 with each slot referring to a integer array i.e. two dimensional arrays in Java are just an array of arrays. Hence you can either use twoDArray[3] = oneDArray; or System.arraycopy if you don't want modifications in the original oneDArray to be reflected in twoDArray. Also read this.

0

thnx for the valuable input...appreciate it..muah.

The twoDArray in your case is just an array of size 10 with each slot referring to a integer array i.e. two dimensional arrays in Java are just an array of arrays. Hence you can either use twoDArray[3] = oneDArray; or System.arraycopy if you don't want modifications in the original oneDArray to be reflected in twoDArray. Also read this.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.