public
synchronized boolean removeElement(Object obj)
Removes
the first occurrence of the argument from this vector. return true if
the argument was a component of this vector, else return false.
import java.util.*; class VectorRemoveElement{ public static void main(String args[]){ Vector<Integer> myVector; myVector = new Vector<> (); /*Add Elements to myVector*/ myVector.add(10); myVector.add(11); myVector.add(12); myVector.add(10); myVector.add(10); System.out.println("Elements in myVector "); System.out.println(myVector); System.out.println("\nRemove First occurrence of 10"); myVector.removeElement(10); System.out.println("Elements in myVector "); System.out.println(myVector); System.out.println("\nRemove First occurrence of 10"); myVector.removeElement(10); System.out.println("Elements in myVector "); System.out.println(myVector); } }
Output
Elements in myVector [10, 11, 12, 10, 10] Remove First occurrence of 10 Elements in myVector [11, 12, 10, 10] Remove First occurrence of 10 Elements in myVector [11, 12, 10]
No comments:
Post a Comment