Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorToStringExample2 { public static void main(String arg[]) { Vector
vec = new Vector
(4); vec.add(1); vec.add(2); vec.add(3); vec.add(4); vec.add(5); //Convert the contents into string vec.toString(); //Display the contents of a vector System.out.println("An elements in vector are :- "); for (Integer number : vec) { System.out.println("Number = " + number); } } }
Output