943,976 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1427
  • Java RSS
Dec 22nd, 2008
0

JAVA: copying 1d array's value into a specific row of a 2d array

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RabbitruN is offline Offline
4 posts
since Dec 2008
Dec 22nd, 2008
0

Re: JAVA: copying 1d array's value into a specific row of a 2d array

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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 720
Failure as a human
~s.o.s~ is offline Offline
8,872 posts
since Jun 2006
Dec 22nd, 2008
0

Re: JAVA: copying 1d array's value into a specific row of a 2d array

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

Click to Expand / Collapse  Quote originally posted by ~s.o.s~ ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RabbitruN is offline Offline
4 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: IP blocking or MAC address blocking
Next Thread in Java Forum Timeline: noclassdeffound error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC