105
Java Vector containsAll() Method
The containsAll() method of Java Vector class is used to check the vector which is in use contains all of the elements in the specified Collection or not. It returns true if this vector contains all of the elements in the Collection, otherwise returns false.
Syntax:
Following is the declaration of containsAll() method:
Parameter:
Parameter | Description | Required/Optional |
---|---|---|
c | It is a collection whose elements will be tested for containment in the vector which is in use. | Required |
Returns:
The containsAll() method returns true if this vector contains all of the elements in the specified collection.
Exceptions:
NullPointerException– This method has thrown an exception if the specified collection is null.
Compatibility Version:
Java 1.2 and above
Example 1:
Output:
Does vector contains all list elements?: true Does vector contains all list elements?: false
Example 2:
Output:
Existence: true Existence: false
Example 3:
Output:
Exception in thread "main" java.lang.NullPointerException at java.base/java.util.Vector.<init>(Vector.java:178) at myPackage.VectorContainsAllExample3.main(VectorContainsAllExample3.java:6)
Next TopicJava Vector