Translate an ArrayList to a Vector in Java


@SuppressWarnings("finally")
public static Vector<String> TranslateArrayListToVector(ArrayList<String> tempArray) {
	Vector<String> newArray = new Vector<String>();
	
	try {		
		for(String temp : tempArray) {
			newArray.add(temp);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}finally {
		return newArray;
	}
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
2 comment(s)Login first to comment...
F van der Linden
(at 09:03 on 04.05.2015)
Another way is by using collections, w

Collections.copy(vector,arrayList);
Martin Rolph
(at 02:26 on 03.05.2015)
I think you can just do

doc.replaceItemValue("MultiValueField", new Vector(viewScope.get("Values")));

as a collection will accept another collection in the constructor