Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorIsEmptyExample3 { public static void main(String arg[]) { //Create an empty Vector Vector < String > colors = new Vector < String > (); //Add color elements in the vector colors.add("Red"); colors.add("Green"); colors.add("Blue"); colors.add("Pink"); //Test the vector if it has no components System.out.println("Vector isEmpty() before? " +colors.isEmpty()); //Remove all elements from the vector colors.removeAllElements(); //Again test the vector if it has no components System.out.println("Vector isEmpty() after ? " +colors.isEmpty()); } }
Output