Javatpoint Logo
Javatpoint Logo

Java Vector removeElement() Method

The removeElement() method of Java Vector class is used to remove the first (lowest-indexed) occurrence of the argument from this vector. Removing an element decreases the vector size by one.

Syntax

Following is the declaration of removeElement() method:

Parameter

Parameter Description Required/Optional
obj It is an element which will be removed from the vector. Required

Return

The removeElement() method returns true if the argument was a component of the vector, otherwise returns false.

Exceptions

NA

Compatibility Version

Java 1.2 and above

Example 1

Test it Now

Output:

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

Example 2

Test it Now

Output:

The elements of a Vector before remove: [Rahul, Karan, Rahul, Rohan]
Is the removal successful?? true
The elements of the Vector after remove: [Karan, Rahul, Rohan]

Next TopicJava Vector





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA