Online Java Compiler By
JavaTpoint.com
import java.util.Vector; public class VectorRemoveAllElementsExample1 { public static void main(String arg[]) { //Create an empty Vector Vector
vc = new Vector<>(); //Add elements in the vector by using add() method vc.add("A"); vc.add("B"); vc.add("C"); //Print the size of vector System.out.println("Size of Vector before removeAllElements() method: "+vc.size()); //removeAllElements from the vector vc.removeAllElements(); System.out.println("Size of Vector after removeAllElements() method: "+vc.size()); } }
Output