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 |
Java Method The elementAt() method of Java Vector class is used to get the element at the specified index in the vector. Syntax Following is the declaration of elementAt() method: public E elementAt(int index) Parameter DataType Parameter Description Required/Optional int index It is an index into this vector. Required Return The elementAt() method returns an element at the specified...
2 min read
Java Method The lastElement() method of Java Vector class is used to get the last component of the vector. Syntax Following is the declaration of lastElement() method: Public E lastElement() Parameter This method does not accept any parameter. Return The lastElement() method returns the last element of the vector i.e. the component...
2 min read
Java Method The size() method of Java Vector class is used to get the number of components presents in the vector. Syntax Following is the declaration of size() method: public int size() Parameter This method does not accept any parameter. Return The size() method returns the number of components presents in a...
2 min read
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 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 remove() Java Vector class method is used to remove the specified element from the vector. There are two different types of Java remove() method which can be differentiated depending on its parameter. These are: Java Vector remove(int index) Method Java Vector remove(Object o) Method remove(int...
3 min read
Java Method The removeRange() method of Java Vector class is used to delete all elements from the vector whose index is between fromIndex, inclusive and toIndex, exclusive. The removal of elements shifts any succeeding elements to the left (reduces their index). Syntax Following is the declaration of...
2 min read
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
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 removeAllElements() method of Java Vector class is used to remove all elements from the vector and set the size of the vector to zero. Syntax Following is the declaration of removeAllElements() method: Public void removeAllElements() Parameter This method does not accept any parameter. Return This method has return type...
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