Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is array copy possible of same dimension

 
Deepika Namasani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Abdulla Mamuwala
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic