As others have pointed out, it is not clear if you "vector" variable is a Vector of Vectors (Vector<Vector<String>>
) or simply a Vector of Strings (Vector<String>
). Please see the following code snippet.
Vector<String> destVector = new Vector<String>();
Vector<String> sourceVector = new Vector<String>();
sourceVector.add("A");
sourceVector.add("B");
sourceVector.add("C");
destVector.addAll(0,sourceVector);
// If your target vector is a vector of vectors (of strings)
Vector<Vector<String>> destVector2 = new Vector<Vector<String>>();
destVector2.set(0,(Vector<String>)sourceVector.clone());
Also, please note that the clone
method returns an Object
. So you will have to explicitly cast to your desired data type.