Java Vector removeRange() Method24 Mar 2025 | 2 min read 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). SyntaxFollowing is the declaration of removeRange() method: Parameter
ReturnThis method does not return anything. It only removed the specified range of an element from the vector. ExceptionsIndexOutOfBoundsException- This method has thrown an exception if the index of an array is out of range i.e. (index < 0 || index >= size()). Compatibility VersionJava 1.2 and above Example 1Output: Vector element before removal: [9, 8, 7, 6, 5] Vector element after removal: [9, 6, 5] Example 2Output: Vector elements: [w, e, l, l, d, c, o, m, e] Vector elements after removal: [w, e, l, c, o, m, e] Next TopicJava Vector Setelementat Method |
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 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
Java Method The isEmpty() method of Java Vector class is used to check if this vector has no components. It returns true if the vector is empty, otherwise returns false. Syntax Following is the declaration of isEmpty() method: Public boolean isEmpty() Parameter This method does not accept any parameter. Return The isEmpty()...
3 min read
Java Method The toArray() Java Vector class method is used to get an array containing all of the elements in this vector in the correct order. There is two different types of Java toArray() method which can be differentiated depending on its parameter. These are: Java...
3 min read
Java Method The removeAll() method of Java Vector class deletes all the elements from the vector that are present in the specified collection. Syntax Following is the declaration of removeAll() method: public boolean removeAll(Collection<?> c) Parameter Parameter Description Required/Optional c It is a collection of elements which will be removed from the vector. Required Return The removeAll()...
3 min read
Java Method The contains() method of Java Vector class is used to check the vector which is in use contains the specified element or not. It returns true if this vector contains the specified element, otherwise returns false. Syntax: Following is the declaration of contains() method: public boolean...
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 hashCode() method of Java Vector class is used to get the hashcode value for the vector which is in use. Syntax: Following is the declaration of hashCode() method: public int hashCode() Parameter: This method does not accept any parameter. Returns: The hashCode() method returns the hash code value for...
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 insertElementAt() method of Java Vector class is used to insert the specified object as a component in this vector at the specified index. Each component in the vector with an index greater or equal to the given index is shifted upward. Now,...
3 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