Java Vector containsAll() Method24 Mar 2025 | 2 min read 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:
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 |
Java Method The retainAll() method of Java Vector class is used to retain only that elements in the vector which are contained in the specified collection. In other words, it removes all elements from this vector that are not contained in the specified collection. Syntax Following is...
3 min read
Java Method The elements() method of Java Vector class used to get an enumeration of the elements of the vector which is in use. The returned enumeration object will generate all items in this vector at the same location. Syntax: Following is the declaration of elements() method: public...
2 min read
Java Method The addAll() Java Vector class method inserts all of the elements in the specified collection to the end of the vector which is in use. The order of the elements will be the same as they are returned by the specified collection's iterator....
5 min read
Java Method The sort() method of Java Vector class is used to sort the vector according to the order induced by the specified Comparator. Syntax Following is the declaration of a sort() method: Public void sort(Comparator<? super E> c) Parameter Parameter Description Required/Optional c It is the Comparator which is used to compare vector...
3 min read
Java Method The spliterator() method of Java Vector class is used to create a late-binding and fail-fast spliterator over the elements in this list. Syntax Following is the declaration of spliterator() method: public Spliterator<E> spliterator() Parameter This method does not accept any parameter. Return The spliterator() method returns a spliterator over the...
2 min read
Java Method The replaceAll() method of Java Vector class is used to replace each element of the list with the result of applying the operator to that element. Syntax Following is the declaration of replaceAll() method: public void replaceAll(UnaryOperator<E> operator) Parameter Parameter Description Required/Optional operator It is an operator which will apply to each...
2 min read
Java Method The indexOf() Java Vector class method is used to get the index of the first occurrence of the specified element in the vector. There are two different types of Java indexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 min read
Java Method The iterator() method of Java Vector class is used to get an iterator over the elements in this list in proper sequence. Syntax Following is the declaration of an iterator() method: Public Iterator<E> iterator() Parameter This method does not accept any parameter. Return The iterator() method returns an iterator over...
2 min read
Java Method The set() method of Java Vector class is used to replace the element at the specified position in the vector with the specified element. Syntax Following is the declaration of set() method: Public E set(int index, E element) Parameter Parameter Description Required/Optional index It is an index of the element which will...
2 min read
Java Method The toString() method of Java Vector class is used to get a string representation of the vector. It contains the string representation of each element. Syntax Following is the declaration of toString() method: public String toString() Parameter This method does not accept any parameter. Return The toString() method returns a...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India