Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Collection; public class JavaCollectionContainsAllExample1 { public static void main(String[] args) { Collection
collection=new ArrayDeque<>(); collection.add("Himanshu"); collection.add("Sham"); collection.add("Rita"); Collection
collection1=new ArrayDeque<>(); collection1.add("Himanshu"); collection1.add("Sham"); collection1.add("Rita"); /*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