Javatpoint Logo
Javatpoint Logo

Java Vector removeElementAt() 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 the value it had previously.


Following is the declaration of removeElementAt() method:


DataType Parameter Description Required/Optional
int index It is an index of the object which will be removed. Required


This method does not return anything. It only removed the element from the vector.


IndexOutOfBoundsException- This method has thrown an exception if the index of an array is out of range i.e. (index < 0 || index >= size()).

Compatibility Version

Java 1.2 and above

Example 1

Test it Now


Vector element before removal: [1, 2, 3, 4, 5, 6]
Vector element after removal: [1, 2, 3, 4, 5]

Example 2

Test it Now


The elements of a vector before removal: [Rahul, Karan, Rahul, Rohan]
The elements of a vector after removal: [Rahul, Karan, Rohan]

Example 3

Test it Now


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50 >= 3
	at java.base/java.util.Vector.removeElementAt(
	at myPackage.VectorRemoveElementAtExample3.main(

Next TopicJava Vector

Youtube For Videos Join Our Youtube Channel: Join Now


  • Send your Feedback to

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA