LinkedBlockingDeque removeIf() method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 on which elements are removed from this Deque. Returns: This method returns a boolean value such as true, if the LinkedBlockingDeque is changed. Else this method returns false. Exceptions: This method throws NullPointerException if the specified Predicate filter is null. Below program illustrates the removeIf() function of LinkedBlockingDeque class : Program 1: Java // Java Program Demonstrate removeIf() // method of LinkedBlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // Create object of LinkedBlockingDeque LinkedBlockingDeque<Integer> LBD = new LinkedBlockingDeque<Integer>(); // Add numbers to end of LinkedBlockingDeque LBD.add(7855642); LBD.add(35658786); LBD.add(5278367); LBD.add(74381793); // Print Deque System.out.println("Linked Blocking Deque: " + LBD); // If a number in the List is // divisible by 3, then remove it LBD.removeIf(number -> number % 3 == 0); System.out.println("Linked Blocking Deque: " + LBD); } } Output: Linked Blocking Deque: [7855642, 35658786, 5278367, 74381793] Linked Blocking Deque: [7855642, 5278367] Program 2: Java // Java Program Demonstrate removeIf() // method of LinkedBlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // Create object of LinkedBlockingDeque LinkedBlockingDeque<Integer> LBD = new LinkedBlockingDeque<Integer>(); // Add numbers to end of LinkedBlockingDeque LBD.add(7855642); LBD.add(35658786); LBD.add(5278367); LBD.add(74381793); // Print Dequeue System.out.println("Linked Blocking Deque: " + LBD); try { // if the predicate is null, // then it will throw NullPointerException LBD.removeIf(null); } catch (Exception e) { System.out.println(e); } } } Output: Linked Blocking Deque: [7855642, 35658786, 5278367, 74381793] java.lang.NullPointerException Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/LinkedBlockingDeque.html#removeIf-java.util.function.Predicate- Comment More infoAdvertise with us Next Article LinkedBlockingDeque removeFirst() method in Java P ProgrammerAnvesh Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-LinkedBlockingDeque +1 More Practice Tags : JavaJava-Collections Similar Reads 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 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 LinkedBlockingQueue take() Method in Java with Examples The take() method of LinkedBlockingQueue is used to retrieve and remove the head of this queue. If the queue is empty then it will wait until an element becomes available. This method is more efficient if working on threads and using LinkedBlockingQueue in that process. So the thread that initially 4 min read 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 LinkedBlockingDeque removeFirst() method in Java The removeFirst() method of LinkedBlockingDeque returns and removes the first element of the Deque container from it. The method throws an NoSuchElementException if the Deque container is empty. Syntax: public E removeFirst() Returns: This method returns the head of the Deque container, which is the 2 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