This creates an array of the proper size, fills it with all the elements in the vector.
You need to cast it to the appropriate type.
import java.util.Vector; public class MainClass { public static void main(String args[]) { Vector v1 = new Vector(); v1.add("A"); v1.add("B"); v1.add("C"); Object[] array = v1.toArray(); for (int i = 0; i < array.length; i++) { System.out.println(array[i]); } } }
A B C