AbstractCollection containsAll() Method in Java with Examples Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report The containsAll() method of Java AbstractCollection is used to check whether two Collections contain the same elements or not. It takes one collection as a parameter and returns True if all of the elements of this collection is present in the other collection. Syntax: AbstractCollection.containsAll(Collection C) Parameters: The parameter C is a Collection. This parameter refers to the collection whose elements occurrence is needed to be checked in this collection. Return Value: The method returns True if this collection contains all the elements of other Collection otherwise it returns False. Below programs illustrate the AbstractCollection.conatinsAll() method: Program 1: // Java code to illustrate boolean containsAll() import java.util.*; class AbstractCollectionDemo { public static void main(String args[]) { // Creating an empty Collection AbstractCollection<String> abs = new LinkedList<String>(); // Use add() method to // add elements in the collection abs.add("Geeks"); abs.add("for"); abs.add("Geeks"); abs.add("10"); abs.add("20"); // Creating another empty Collection AbstractCollection<String> abs2 = new LinkedList<String>(); // Use add() method to // add elements in the collection abs2.add("Geeks"); abs2.add("for"); abs2.add("Geeks"); abs2.add("10"); abs2.add("20"); // Check if the collection // contains same elements System.out.println("\nBoth the collections same: " + abs.containsAll(abs2)); } } Output: Both the collections same: true Program 2: // Java code to illustrate boolean containsAll() import java.util.*; class AbstractCollectionDemo { public static void main(String args[]) { // Creating an empty Collection AbstractCollection<String> abs = new LinkedList<String>(); // Use add() method to // add elements in the collection abs.add("Geeks"); abs.add("for"); abs.add("Geeks"); // Creating another empty Collection AbstractCollection<String> abs2 = new LinkedList<String>(); // Use add() method to // add elements in the collection abs2.add("10"); abs2.add("20"); // Check if the collection // contains same elements System.out.println("\nBoth the collections same: " + abs.containsAll(abs2)); } } Output: Both the collections same: false Feeling lost in the vast world of Backend Development? It's time for a change! Join our Java Backend Development - Live Course and embark on an exciting journey to master backend development efficiently and on schedule. What We Offer: Comprehensive Course Expert Guidance for Efficient Learning Hands-on Experience with Real-world Projects Proven Track Record with 100,000+ Successful Geeks Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore. Last Updated : 26 Nov, 2018 Like Article Save Article Previous AbstractCollection addAll() Method in Java with Examples Next AbstractCollection retainAll() method in Java with Examples Share your thoughts in the comments Add Your Comment Please Login to comment...