public
boolean remove(Object o)
Removes
the first occurrence of the specified object in this Vector. Return
true if the Vector contained the specified element.
import java.util.*; class VectorRemoveObject{ public static void main(String args[]){ Vector<Integer> myVector; ListIterator<Integer> myIter; myVector = new Vector<> (); /*Add Elements to myVector*/ myVector.add(10); myVector.add(11); myVector.add(12); myVector.add(13); myVector.add(14); Integer i1 = new Integer(10); System.out.println("Elements in myVector are "); System.out.println(myVector); System.out.println("\nRemoving element 10"); myVector.remove(i1); System.out.println("\nElements in myVector are "); System.out.println(myVector); } }
Output
Elements in myVector are [10, 11, 12, 13, 14] Removing element 10 Elements in myVector are [11, 12, 13, 14]
No comments:
Post a Comment