Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSizeExample1 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add element in the vector vec.add(10); vec.add(20); vec.add(30); vec.add(40); vec.add(50); //Displaying the vector element System.out.println("The vector Element is = "+vec); //Get the number of components in the vector System.out.println("Size of the vector is = "+vec.size()); } }
Output