File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes cloning array of vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cloning array of vectors" Watch "cloning array of vectors" New topic

cloning array of vectors

Dalibor Toth
Ranch Hand

Joined: Jul 16, 2001
Posts: 38
How do I clone array of vectors?
This works only for one vector:
Vector vector2 = (Vector)vector.clone();
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
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

Joined: Jul 16, 2001
Posts: 38
Sorry, maybe I wasn't too clear:
I have vector v that contains 3 vectors and I need to clone it.
I agree. Here's the link:
subject: cloning array of vectors
It's not a secret anymore!