• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Clone-deep copy  RSS feed

 
Ian glasgow
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I know there's lots of info and posts about Cloning Objects, but I still can't get my head round it.
All I want to do is make three identical copies of an Array so when I sort them, using different sort methods, I can make comparisions between how long it took on each Array.
If I just do this:
anArray = arrayOne;
anArray = arrayTwo;
etc..
I'm just making multiple refeences/pointers to the same Array. Correct?
So how do I use the "clone" stuff. I really can not understand how it works and I can't get it to work. The original array is created in my class constructor.
Help??
Thanks..
Ian
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anArray = ( (correct array type here)[] ) anArrayOne.clone();
 
Ian glasgow
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
Seems to have done the trick
Later..
Ian
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!