LinkedBlockingDeque addAll() method in Java with Examples Last Updated : 11 Jun, 2021 Comments Improve Suggest changes Like Article Like Report 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 // 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("ArrayList: " + 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 // 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("ArrayList: " + ArrLis); // Function addAll() adds all the elements of // ArrayList to Deque LBD.addAll(ArrLis); // Print deque System.out.println("Linked Blocking Deque: " + LBD); } } Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/LinkedBlockingDeque.html#addAll-java.util.Collection- Comment More infoAdvertise with us Next Article LinkedBlockingDeque addAll() method in Java with Examples P ProgrammerAnvesh Follow Improve Article Tags : Java Java - util package Java-Functions Java-LinkedBlockingDeque Practice Tags : Java Similar Reads LinkedBlockingDeque forEach() method in Java with Examples The forEach() method of LinkedBlockingDeque performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Syntax: public void forEach(Consumer<E> action) Parameters: This method takes a parameter action which represents the 2 min read LinkedBlockingDeque in Java with Examples The LinkedBlockingDeque class in Java is a part of the Java Collection Framework. It was introduced in JDK 1.6 and it belongs to java.util.concurrent package. It is a Deque(Doubly Ended Queue) which blocks a thread if that thread tries to take elements out of it while the Deque is empty. It implemen 14 min read LinkedBlockingDeque addLast() method in Java The addLast(E e) method of LinkedBlockingDeque inserts the element passed in the parameter to the end of the Deque if there is space. If the LinkedBlockingDeque is capacity restricted and no space is left for insertion, it returns an IllegalStateException. Syntax: public void addLast(E e) Parameters 2 min read LinkedBlockingDeque retainAll() method in Java with Examples The retainAll() method of LinkedBlockingDeque is an in-built function is Java which is used to remove from this deque all of its elements that are contained in the specified collection. That means, all the common elements these two collections are removed from this deque. Syntax: public boolean reta 2 min read LinkedBlockingDeque removeAll() method in Java with Examples The removeAll() method of LinkedBlockingDeque is an in-built function is Java which is used to remove from this deque all of its elements that are contained in the specified collection. That means, all the common elements these two collections are removed from this deque.Syntax: public boolean remov 2 min read Like