Javatpoint Logo
Javatpoint Logo

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:

Test it Now

Output:

Does vector contains all list elements?: true
Does vector contains all list elements?: false

Example 2:

Test it Now

Output:

Existence: true
Existence: false

Example 3:

Test it Now

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA