LinkedTransferQueue removeAll() method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 a parameter containing elements to be removed from this list. Returns: This method returns true if this list changed as a result of the call. Exceptions: NULL Pointer Exception if this list contains a null element. Below program illustrates the removeAll() function of LinkedTransferQueue class : Program 1: Java // Java code to illustrate // removeAll() method of LinkedTransferQueue import java.util.concurrent.LinkedTransferQueue; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of LinkedTransferQueue LinkedTransferQueue<String> LTQ = new LinkedTransferQueue<String>(); // Add numbers to end of LinkedTransferQueue // using add() method LTQ.add("GeeksforGeeks"); LTQ.add("Geeks"); LTQ.add("Computer Science"); LTQ.add("Portal"); LTQ.add("Gfg"); // Print the Queue System.out.println("Linked Transfer Queue : " + LTQ); // Get the ArrayList to be deleted ArrayList<String> arraylist = new ArrayList<String>(); arraylist.add("GeeksforGeeks"); arraylist.add("Gfg"); arraylist.add("hack"); // Print ArrayList System.out.println("ArrayList to be deleted : " + arraylist); // Removing elements from the queue // which are common to arraylist // using removeAll() method. LTQ.removeAll(arraylist); // Prints the Queue System.out.println("Linked Transfer Queue " + "after removal of ArrayList : " + LTQ); } } Output: Linked Transfer Queue : [GeeksforGeeks, Geeks, Computer Science, Portal, Gfg] ArrayList to be deleted : [GeeksforGeeks, Gfg, hack] Linked Transfer Queue after removal of ArrayList : [Geeks, Computer Science, Portal] Program 2: Java // Java code to illustrate // removeAll() method of LinkedTransferQueue import java.util.concurrent.LinkedTransferQueue; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of LinkedTransferQueue LinkedTransferQueue<Integer> LTQ = new LinkedTransferQueue<Integer>(); // Add numbers to end of LinkedTransferQueue // using add() method LTQ.add(3); LTQ.add(6); LTQ.add(10); LTQ.add(125); LTQ.add(205); // print the Queue System.out.println("Linked Transfer Queue : " + LTQ); // Get the ArrayList to be deleted ArrayList<Integer> arraylist = new ArrayList<Integer>(); arraylist.add(10); arraylist.add(100); arraylist.add(125); // Print ArrayList System.out.println("ArrayList to be deleted : " + arraylist); // Removing elements from the queue // which are common to arraylist // using removeAll() method. LTQ.removeAll(arraylist); // Prints the Queue System.out.println("Linked Transfer Queue " + "after removal of ArrayList : " + LTQ); } } Output: Linked Transfer Queue : [3, 6, 10, 125, 205] ArrayList to be deleted : [10, 100, 125] Linked Transfer Queue after removal of ArrayList : [3, 6, 205] Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/LinkedTransferQueue.html#removeAll-java.util.Collection- Comment More infoAdvertise with us Next Article LinkedTransferQueue retainAll() method in Java with Examples P ProgrammerAnvesh Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-LinkedTransferQueue +1 More Practice Tags : JavaJava-Collections Similar Reads LinkedTransferQueue removeIf() method in Java with Examples The removeIf() method of java.util.concurrent.LinkedTransferQueue is an in-built function is Java which is used to remove all of the elements of this queue that satisfies a given predicate filter which is passed as a parameter to the method. Syntax: public boolean removeIf(Predicate filter) Paramete 2 min read LinkedTransferQueue retainAll() method in Java with Examples The retainAll() method of java.util.concurrent.LinkedTransferQueue is an in-built function in Java which is used to retain all the elements in this queue which are common to both i.e. the specified collection and this queue. All other elements which are not common are removed from this queue. Syntax 3 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 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 LinkedTransferQueue remove() method in Java The java.util.concurrent.LinkedTransferQueue.remove() method is an in-built function in Java which is used to remove an element if it is present in this queue. Syntax: LinkedTransferQueue.remove(Object o) Parameters: The function accepts a single parameter o i.e. the object to be removed. Return Val 2 min read List removeAll() method in Java with Examples This method is used to remove all the elements present in the collection from the specified list. Syntax: boolean removeAll(Collection c) Parameters: This method has only argument, collection of which elements are to be removed from the given list. Returns: This method returns True if elements are r 2 min read Like