This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: cloning array of vectors
It's not a secret anymore!