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

Thread Solved
Reply

Join Date: Dec 2008
Posts: 4
Reputation: RabbitruN is an unknown quantity at this point 
Solved Threads: 0
RabbitruN RabbitruN is offline Offline
Newbie Poster

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

 
0
  #1
Dec 22nd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,582
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 461
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

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

 
0
  #2
Dec 22nd, 2008
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.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 4
Reputation: RabbitruN is an unknown quantity at this point 
Solved Threads: 0
RabbitruN RabbitruN is offline Offline
Newbie Poster

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

 
0
  #3
Dec 22nd, 2008
thnx for the valuable input...appreciate it..muah.

Originally Posted by ~s.o.s~ View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC