How to convert a vector to a list?
Vector is a concrete class that implements the List interface so technically it is already a List
. You can do this:
List list = new Vector();
or:
List list = new Vector();
(assuming a Vector
of String
s).
If however you want to convert it to an ArrayList, which is the closest List
implementation to a `Vector~ in the Java Collections Framework then just do this:
List newList = new ArrayList(vector);
or for a generic version, assuming a Vector
of String
s:
List newList = new ArrayList(vector);