Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Predicate; public class ConcurrentLinkedQueueRemoveIfExample3 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); for (int i=1;i<21;i++){ queue.add(i);} System.out.println("Total no : "+ queue); //removes all the elements which satisfies the predicate filter Predicate
pr=null; queue.removeIf(pr ); System.out.println(queue); } }
Output