Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Collection; public class JavaCollectionRemoveExample3 { public static void main(String[] args) { Collection
collection = new ArrayDeque
() { }; collection.add("Reema"); collection.add("Geetanajli"); //pass an exception for null elements collection.add(null); for (String i:collection) { System.out.println(i); } //will remove the specified element from the collection boolean val=collection.remove("ABC"); System.out.println("Remove method will return : "+val); } }
Output