share

Thursday, 21 May 2015

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]

No comments:

Post a Comment