Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSizeExample2 { public static void main(String arg[]) { //Create an empty vector Vector < String > colors = new Vector < String > (10); //Add elements in the vector colors.add("White"); colors.add("Green"); colors.add("Black"); colors.add("Pink"); //Get the number of components in the vector System.out.println("Size of the vector is = "+colors.size()); } }
Output