Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Collection; public class JavaCollectionContainsAllExample2 { public static void main(String[] args) { Collection
collection=new ArrayDeque<>(); collection.add("Himanshu"); collection.add("Sham"); collection.add("Rita"); Collection
collection1=new ArrayDeque<>(); //it will give an exception as it does not support null elements. collection1.add(null); /*containsAll() method will return a boolean value true if all the elements are present in the invoked collection*/ System.out.println(collection.containsAll(collection1)); } }
Output