The Containsall method is used to determine whether the set collection contains the entire contents of another collection.
Syntax Boolean containsall (collection<?> c)
Return value: Returns True if the Set collection contains all of the contents of the collection object specified by the parameter C, otherwise false is returned.
Parameter: C is another collection object to be judged.
Example This example first creates a set collection, adds some objects, and then creates a list collection with the same contents as the set collection, calling the Containsall method to determine whether the Set collection contains the contents of the list collection.
public static void Main (string[] args) {
Set set = new HashSet ();
Set.add (New Date ()); Add data to the list
Set.add ("Apple"); Add data to the list
Set.add (New Socket ()); Add data to the list
Set.add ("TV"); Add data to the list
List list=new ArrayList ();
List.add ("Apple"); Add data to the list
List.add ("TV"); Add data to the list
Boolean contains = Set.containsall (list);
if (contains) {
System.out.println ("Set collection contains the contents of the list collection");
} else {
System.out.println ("Set collection does not contain the contents of the list collection");
}
}
Set collection about set and set comparison