permaculture playing cards*
The moose likes Beginning Java and the fly likes is array copy possible of same dimension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "is array copy possible of same dimension" Watch "is array copy possible of same dimension" New topic
Author

is array copy possible of same dimension

Deepika Namasani
Greenhorn

Joined: May 19, 2005
Posts: 25
hi all is there any way to copy one array into another without a loop
i am sure there is one. I know both arrays of same dimesion.

but if it some thing like this

where newCentroids[] is a float array of size 3 and and CentroidValues(ArrayList ar[3]) is a method that return a float array.

my program shows an error at this point



Deepika N
Abdulla Mamuwala
Ranch Hand

Joined: Jan 09, 2004
Posts: 225
Deepika what is he error you are getting ?

Is this error being caused because you are trying to assign an array of type float to an ArrayList.



and than later you try this,


[ June 24, 2005: Message edited by: Abdulla Mamuwala ]
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Dear Deepika,
I don't know whether what I am going to say is right or wrong. In case I am wrong I would appreciate it if somebody corrected me.
Ok, so I noticed that when you were assigning the values to the array then at that point of time you were not declaring the array. This means that you must have already declared the array and now you want to simply initialize it. Your statement was as follows:


The correct one should have been this way:


You notice the elimination of the square brackets in the second case. That should not be there when you are declaring and initializing the array differently. But at the time of declaration the square brackets are necessary.

NOTE: If what I said was correct then please post a small post saying that my solution was helpful as even I am not sure whether what I said was right.


With Best Regards,
Shyam Prasad Murarka
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is array copy possible of same dimension