Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cloning array of vectors

 
Dalibor Toth
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I clone array of vectors?
This works only for one vector:
Vector vector2 = (Vector)vector.clone();
Thanks!
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could create a vector of vectors instead of and array of vectors, first of all. Or better yet, a list of lists. You could also just make a boring loop:
Vector[] copy = new Vector[old.length];
for (int i = 0; i < old.length; old++) {
copy[i] = old[i].clone();
}
 
Dalibor Toth
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, maybe I wasn't too clear:
I have vector v that contains 3 vectors and I need to clone it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic