protected
synchronized void removeRange(int fromIndex, int toIndex)
Removes
from this list all of the elements whose index is between fromIndex,
inclusive, and toIndex, exclusive.
import java.util.*; class VectorRemoveRange<Integer> extends Vector<Integer>{ public static void main(String args[]){ VectorRemoveRange myVector; myVector = new VectorRemoveRange<> (); /*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 the elements from index 1 to 3"); myVector.removeRange(1, 3); System.out.println("\nElements in myVector "); System.out.println(myVector); } }
Output
Elements in myVector [10, 11, 12, 10, 10] Remove the elements from index 1 to 3 Elements in myVector [10, 10, 10]
No comments:
Post a Comment