How to create Vector In java

import java.util.Vector;

public class CreateVector {

public static void main(String[] args) {

Vector<String> vector = new Vector<String>();

//add element in vector
vector.add(“cricket”);
vector.add(“hockey”);
vector.add(“football”);
vector.add(“tennish”);

// print vector
System.out.println(“Vector = “+vector);

}
}

Output:

Vector = [cricket, hockey, football, tennish]

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 1 =