How to create an object of Vector - Java Collection Framework

Java examples for Collection Framework:Vector

Description

How to create an object of Vector

Demo Code

 
import java.util.Iterator;
import java.util.Vector;
 
public class Main {
 
  public static void main(String[] args) {
    Vector v = new Vector();
    v.add("1");//  ww  w  . j  a v a2s  . c  o m
    v.add("2");
    v.add("3");
    System.out.println("Getting elements of Vector");
    System.out.println(v.get(0));
    System.out.println(v.get(1));
    System.out.println(v.get(2));
  }
}

Result


Related Tutorials