Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Predicate; public class JavaCollectionRemoveIfExample3 { public static void main(String[] args) { Collection
collection = new ConcurrentLinkedQueue
(); char c; for(c='A';c<='Z';++c){ collection.add(c); } System.out.println("Albabets : "+ collection); //removes all the elements which satisfies the predicate filter Predicate
pr= a->(a!='A'&& a!='E'&& a!='I'&& a!='O'&& a!='U' ); //remove all the non vowels alphabets collection.removeIf(pr ); System.out.println(" Vowels = "+collection); } }
Output