LinkedBlockingDeque addAll() method in Java with Examples
The addAll() method of LinkedBlockingDeque appends all of the elements of the specified collection to the end of this deque.
Syntax:
public void addAll(Collection<E> c)
Parameters: This method accepts a mandatory parameter c which is the collection to be inserted in the end of the LinkedBlockingDeque.
Return Value: This method does not returns anything.
Exceptions: There are 2 exceptions present:-
- IllegalStateException: if the collection cannot be added at this time due to capacity restrictions.
- NullPointerException: if the specified collection is Null.
Below program illustrates the addAll() function of LinkedBlockingDeque class:
Example1:
// Java Program Demonstrate addAll() // method of LinkedBlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws IllegalStateException { // Create object of LinkedBlockingDeque LinkedBlockingDeque<Integer> LBD = new LinkedBlockingDeque<Integer>(); // Add numbers to end of LinkedBlockingDeque LBD.add(11); LBD.add(22); LBD.add(33); LBD.add(44); // Print deque System.out.println("Linked Blocking Deque: " + LBD); // Create object of ArrayList collection ArrayList<Integer> ArrLis = new ArrayList<Integer>(); // Add number to ArrayList ArrLis.add(55); ArrLis.add(66); ArrLis.add(77); ArrLis.add(88); // Print ArrayList System.out.println("ArraList: " + ArrLis); // Function addAll() adds all the elements of // ArrayList to Deque LBD.addAll(ArrLis); // Print deque System.out.println("Linked Blocking Deque: " + LBD); } } |
Example 2:
// Java Program Demonstrate addAll() // method of LinkedBlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws IllegalStateException { // Create object of LinkedBlockingDeque LinkedBlockingDeque<String> LBD = new LinkedBlockingDeque<String>(); // Add elements to end of LinkedBlockingDeque LBD.add("GeeksforGeeks"); LBD.add("Gfg"); LBD.add("Geeks"); // Print deque System.out.println("Linked Blocking Deque: " + LBD); // Create object of ArrayList collection ArrayList<String> ArrLis = new ArrayList<String>(); // Add elements to ArrayList ArrLis.add("Computer"); ArrLis.add("Science"); ArrLis.add("Portal"); // Print ArrayList System.out.println("ArraList: " + ArrLis); // Function addAll() adds all the elements of // ArrayList to Deque LBD.addAll(ArrLis); // Print deque System.out.println("Linked Blocking Deque: " + LBD); } } |
Recommended Posts:
- Set addAll() method in Java with Examples
- Collection addAll() method in Java with Examples
- SortedSet addAll() method in Java with Examples
- Collections addAll() method in Java with Examples
- AbstractSequentialList addAll() Method in Java with Examples
- List addAll() Method in Java with Examples
- AbstractList addAll() method in Java with Examples
- CopyOnWriteArraySet addAll() method in Java with Examples
- AbstractQueue addAll() method in Java with examples
- ConcurrentLinkedDeque addAll() method in Java with Examples
- CopyOnWriteArrayList addAll() method in Java with Examples
- AbstractCollection addAll() Method in Java with Examples
- LinkedBlockingDeque removeAll() method in Java with Examples
- LinkedBlockingDeque retainAll() method in Java with Examples
- LinkedBlockingDeque forEach() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



