![]() |
VOOZH | about |
In Java, the addAll() method is used to add all elements from a specified Collection to the current Vector. The addAll() method allows you to efficiently append multiple elements to a vector in one operation.
Implementation:
Vector : [1, 2, 3]
Now there are two versions of Vector addAll() method i.e one with the specified index and one without any index.
This method is used to append all of the elements from the collection passed as a parameter to this function to the end of a vector keeping in mind the order of return by the collection's iterator.
Syntax:
boolean addAll(Collection C)
Parameters: The method accepts a mandatory parameter C which is a collection of ArrayList. It is the collection whose elements are needed to be appended at the end of the vector.
Return Value: The method returns True if at least one action of append is performed, else False.
Below program illustrate the Java.util.Vector.addAll() method:
The vector is: [Geeks, for, Geeks] The new vector is: [Geeks, for, Geeks, A, Computer, Portal, for, Geeks]
This method is used to append all of the elements from the collection passed as a parameter to this function at a specific index or position of a vector.
Syntax:
boolean addAll(int index, Collection C)
Parameters: This function accepts two parameters as shown in the above syntax and are described below.
Example:
Vector : [1, 2, 3, 4]