Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Predicate; public class ConcurrentLinkedQueueRemoveIfExample1 { 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= a->(a>10); queue.removeIf(pr ); System.out.println(" Number less than 11 = "+queue); } }
Output