Stack addAll(int, Collection) method in Java with Example
The addAll(int, Collection) method of Stack Class 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 Stack.
boolean addAll(int index, Collection C)
Parameters: This function accepts two parameters as shown in the above syntax and are described below.
- index: This parameter is of integer datatype and specifies the position in the Stack starting from where the elements from the container will be inserted.
- C: It is a collection of ArrayList. It is the collection whose elements are needed to be appended.
Return Value: The method returns True if at least one action of append is performed, else False.
Below program illustrate the Java.util.Stack.addAll() method:
The Stack is: [Geeks, for, Geeks, 10, 20] The new Stack is: [Geeks, A, Computer, Portal, for, Geeks, for, Geeks, 10, 20]
The Stack is: [10, 20, 30, 40, 50] The new Stack is: [10, 20, 1, 2, 3, 30, 40, 50]
My Personal Notes arrow_drop_up
Please Login to comment...