88
Java Vector addElement() Method
The addElement() method of Java Vector class is used to add the specified element to the end of this vector. Adding an element increases the vector size by one.
Syntax:
Following is the declaration of addElement() method:
Parameter:
Parameter | Description | Required/Optional |
---|---|---|
e | It is the element which will be added to the vector. | Required |
Returns:
The addElement() method does not return anything because its return type is void.
Exceptions:
NA
Compatibility Version:
Java 1.2 and above
Example 1:
Output:
--Elements of Vector are-- Element= A Element= B Element= C ---Elements after addition--- Element= A Element= B Element= C Element= TutorAspire
Example 2:
Output:
Elements of Vector are: [101, -201, 301] Elements of vector after addition: [101, -201, 301, -5001]
Next TopicJava Vector