Removes all of the elements of this collection that satisfy the given predicate.

package com.logicbig.example.arrayblockingqueue;
import java.util.Arrays;
import java.util.concurrent.ArrayBlockingQueue;
public class RemoveIfExample {
public static void main(String... args) {
ArrayBlockingQueue<Integer> q = new ArrayBlockingQueue<>(3, true, Arrays.asList(3, 6, 8));
System.out.println("queue before: " + q);
//if multiple of 3
q.removeIf((i) -> i % 3 == 0);
System.out.println("queue after: " + q);
}
}
Output
queue before: [3, 6, 8]
queue after: [8]