Vector class addElement(E obj)method example
Adds the specified component to the end of this vector, increasing its size by one.
Vector class addElement(E obj)method example. This example shows you how to use addElement(E obj) method.This method Adds the specified component to the end of this vector, increasing its size by one.
Here is the code:-
/*
* @Program that Adds the specified component to the end of this vector,
increasing its size by one.
* AddElement.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class AddElement {
public static void main(String[] args) {
//creating vector
Vector v=new Vector();
//Adds the specified component to the end of this vector
v.addElement("vikas");
v.addElement("girish");
v.addElement("mahendra");
v.addElement("komal");
Enumeration e=v.elements();
System.out.print("Vector after adding element is : " );
while(e.hasMoreElements())
{
System.out.print(e.nextElement()+"\t");
}
}
} |
Output of the program:-
| Vector after adding element is : vikas girish mahendra komal |
|