Vector addElement() Method in Java
The Java.util.Vector.addElement() method is used to append a specified element to the end of this vector by increasing the size of the vector by 1. The functionality of this method is similar to that of the add() method of Vector class.
boolean addElement(Object element)
Parameters: This function accepts a single parameter element of object type and refers to the element specified by this parameter is appended to end of the vector.
Return Value: This is a void type method and does not returns any value.
Below programs illustrate the working of java.util.Vector.add(Object element) method.
Program 1 :
The vector is: [Geeks, for, Geeks, 10, 20] The new Vector is: [Geeks, for, Geeks, 10, 20, Last, Element]
The vector is: [1, 2, 3, 10, 20] The new Vector is: [1, 2, 3, 10, 20, 50, 100]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.