LinkedBlockingDeque removeAll() method in Java with Examples Last Updated : 22 Jul, 2021 Comments Improve Suggest changes Like Article Like Report 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 removeAll(Collection c) Parameters: This method takes collection c as a parameter containing elements to be removed from this list.Return Value: This method returns true if this deque changed as a result of the call.Exceptions: This method throws NULL Pointer Exception if the specified collection is Null.Below program illustrates the removeAll() function of LinkedBlockingDeque class:Example 1: Java // Java Program Demonstrate removeAll() // 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(11); ArrLis.add(23); ArrLis.add(22); // print ArrayList System.out.println("ArrayList to be removed: " + ArrLis); // function removeAll() removes all // the common elements from deque LBD.removeAll(ArrLis); // print deque System.out.println("Current Linked Blocking Deque: " + LBD); } } OutputLinked Blocking Deque: [11, 22, 33, 44] ArrayList to be removed: [55, 11, 23, 22] Current Linked Blocking Deque: [33, 44] Example 2: Java // Java Program Demonstrate removeAll() // 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 numbers to end of LinkedBlockingDeque LBD.add("geeks"); LBD.add("Geeks"); LBD.add("gfg"); LBD.add("Gfg"); // print deque System.out.println("Linked Blocking Deque: " + LBD); // create object of ArrayList collection ArrayList<String> ArrLis = new ArrayList<String>(); // Add number to ArrayList ArrLis.add("GeeksforGeeks"); ArrLis.add("Geeks"); ArrLis.add("gfg"); ArrLis.add("Gfg"); // print ArrayList System.out.println("ArrayList: " + ArrLis); // function removeAll() removes all // the common elements from deque LBD.removeAll(ArrLis); // print deque System.out.println("Linked Blocking Deque: " + LBD); } } OutputLinked Blocking Deque: [geeks, Geeks, gfg, Gfg] ArrayList: [GeeksforGeeks, Geeks, gfg, Gfg] Linked Blocking Deque: [geeks] Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/LinkedBlockingDeque.html#removeAll-java.util.Collection- Comment More infoAdvertise with us Next Article LinkedBlockingDeque removeAll() 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 removeIf() method in Java with Examples The removeIf() method of LinkedBlockingDeque removes the element from this LinkedBlockingDeque that satisfies the specified condition. Syntax: public boolean removeIf (Predicate<? super E> filter) Parameters: This method accepts a mandatory parameter filter which is the predicate value based o 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 LinkedTransferQueue removeAll() method in Java with Examples The removeAll() method of java.util.concurrent.LinkedTransferQueue is an in-built function is Java which is used to remove from this queue all of its elements that are contained in the specified collection. Syntax: public boolean removeAll(Collection c) Parameters: This method takes collection c as 3 min read LinkedHashSet removeAll() method in Java with Example The removeAll() method of java.util.LinkedHashSet class is used to remove from this set all of its elements that are contained in the specified collection. Syntax: public boolean removeAll(Collection c) Parameters: This method takes collection c as a parameter containing elements to be removed from 3 min read LinkedBlockingDeque remove() method in Java The remove() method of LinkedBlockingDeque removes the head of the Deque container. The method throws a NoSuchElementException if the Deque container is empty. Syntax: public E remove() Parameters: This method does not accepts any parameter. Returns: This method does not returns anything. Exception: 2 min read Like