How to Remove all elements from vector?

In this example, we will see how to remove all the elements from a Vector. We will be using clear() method of Vector class

package test;

import java.util.Vector;
 
public class RemoveAll {
 
    public static void main(String a[]){
        Vector<String> vct = new Vector<String>();
        //adding elements to the end
        vct.add("Selenium");
        vct.add("Java");
        vct.add("UFT");
        vct.add("Other");
        System.out.println("Actual vector:"+vct);
        vct.clear();
        System.out.println("After clear vector:"+vct);
    }
}

Output:

Actual vector:[Selenium, Java, UFT, Other]
After clear vector:[]

The only business I know is learning new technology and spreading the knowledge. I believe sharing is learning. This is my prime reason to build this site.
I welcome and value your comments, suggestions and corrections.

49total visits,1visits today

The only business I know is learning new technology and spreading the knowledge. I believe sharing is learning. This is my prime reason to build this site. I welcome and value your comments, suggestions and corrections.