VOOZH about

URL: https://www.geeksforgeeks.org/java/vector-addelement-method-in-java/

⇱ Vector addElement() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Vector addElement() Method in Java

Last Updated : 11 Jul, 2025

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.

Syntax:

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.

Example of Vector addElement() Method

Below programs illustrate the working of java.util.Vector.add(Object element) method.

Example 1 : 


Output
The vector is : [Geeks, for, Geeks]
The new Vector is : [Geeks, for, Geeks, Last, Element]

Example 2:


Output
The vector is : [1, 2, 3]
The new vector is : [1, 2, 3, 50, 100]
Comment