Java Vector removeAll() Method24 Mar 2025 | 2 min read The removeAll() method of Java Vector class deletes all the elements from the vector that are present in the specified collection. SyntaxFollowing is the declaration of removeAll() method: Parameter
ReturnThe removeAll() method returns true if the vector changed as a result of the call. ExceptionsNullPointerException- This method has thrown an exception if the vector contains one or more null elements and the specified collection does not support null elements or if the specified collection is null. Compatibility VersionJava 1.2 and above Example 1Output: Vector: [1, 2, 3, 4, 5] Removing all the elements Size of the vector: 0 Example 2Output: Vector: [A, B, C, 10, 20] Collection removed Final Vector: [10, 20] Next TopicJava Vector |
Vector listIterator()
Java Method The listIterator() Java Vector class method returns a list iterator over the elements in the given list in a proper sequence. There is two different types of Java listIterator() method which can be differentiated depending on its parameter. These are: Java Method Java Vector...
4 min read
Vector removeElementAt()
Java Method The removeElementAt() method of Java Vector class is used to delete the component at the specified index. Each element in this vector with an index greater or equal to the given index is shifted downward. Now the vector index is one smaller than...
2 min read
Vector addAll()
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
Vector lastIndexOf()
Java Method The lastIndexOf() Java Vector class method is used to get the index of the last occurrence of the specified element in the vector. There are two different types of Java lastIndexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 min read
Vector replaceAll()
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
Vector copyInto()
Java Method The copyInto() method of Java Vector class used to copy the elements of the vector which is in use into the specified array. In this, the position of the elements is the same in both the vector and an array. Syntax: Following is the declaration...
3 min read
Vector toString()
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
Vector firstElement()
Java Method The firstElement() method of Java Vector class is used to get the first element ( at index 0 ) of the vector which is in use. Syntax: Following is the declaration of firstElement() method: public E firstElement() Parameter: This method does not accept any parameter. Returns: The firstElement() method returns...
2 min read
Vector get()
Java Method The get() method of Java Vector class is used to get the element at the specified position in the vector. Syntax Following is the declaration of get() method: public E get(int index) Parameter DataType Parameter Description Required/Optional int index It is an index of the element which will be returned. Required Return The get() method returns the...
2 min read
Vector setElementAt()
Java Method The setElementAt() method of Java Vector class is used to replace the component at the specified index of this vector to be the specified object. Syntax Following is the declaration of setElementAt() method: public void setElementAt(E obj, int index) Parameter Parameter Description Required/Optional index It is the specified index where an element...
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