Tuesday, 6 May 2014

Vector : addElement : add Element to Vector

public synchronized void addElement(E obj)
Adds the specified component to the end of this vector.

import java.util.*;

class VectorAddElement{
 public static void main(String args[]){
  Vector<Integer> myVector;
  myVector = new Vector<> ();
  
  /* Add Elements to myVector */
  myVector.addElement(40);
  myVector.addElement(50);
  myVector.addElement(60);
  
  System.out.println("Elements in myVector are");
  System.out.println(myVector);
 }
}

Output
Elements in myVector are
[40, 50, 60]

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment