Vector extends AbstractList<E> implements List<E>, RandomAccess { public synchronized void removeElementAt(int index) { modCount++; if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } returnToPool(elementData[index]); int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; } Vector(int initialCapacity);  Vector(); synchronized void copyInto(Object[] anArray); synchronized int capacity(); synchronized int size(); synchronized boolean isEmpty(); Enumeration<E> elements(); boolean contains(Object o); int indexOf(Object o); synchronized int indexOf(Object o, int index); synchronized int lastIndexOf(Object o); synchronized int lastIndexOf(Object o, int index); synchronized E elementAt(int index); synchronized E firstElement(); synchronized E lastElement(); synchronized void setElementAt(E obj, int index); synchronized void removeElementAt(int index); synchronized void insertElementAt(E obj, int index); synchronized void addElement(E obj); synchronized boolean removeElement(Object obj); synchronized void removeAllElements(); synchronized Object[] toArray(); synchronized T[] toArray(T[] a); synchronized E get(int index); synchronized E set(int index, E element); synchronized boolean add(E e); boolean remove(Object o); void add(int index, E element); synchronized E remove(int index); void clear(); synchronized boolean equals(Object o); synchronized int hashCode(); synchronized String toString();  }
@Test public void testRemoveElementAt() { Vector<MyPoolObject> fixture = new Vector<MyPoolObject>(); ObjectPool<MyPoolObject> objectPool = new ObjectPool<MyPoolObject>( new MyFactory()); MyPoolObject[] objectArray = new MyPoolObject[10]; for(int i = 0; i < objectArray.length; i++){ objectArray[i] = objectPool.getPoolObject(); } for(int i = 0; i< fixture.capacity(); i++){ fixture.add(objectArray[i]); } assertEquals(10, objectPool.usedObjects()); assertEquals(10, fixture.size()); fixture.removeElementAt(5); assertEquals(4,fixture.elementAt(4).number); assertEquals(6,fixture.elementAt(5).number); assertEquals(9, fixture.size()); assertEquals(9, objectPool.usedObjects); fixture.removeElementAt(5); assertEquals(4,fixture.elementAt(4).number); assertEquals(7,fixture.elementAt(5).number); assertEquals(8, fixture.size()); assertEquals(8, objectPool.usedObjects); int size = fixture.size(); try { fixture.removeElementAt(size+1); } catch (ArrayIndexOutOfBoundsException e) { assertNotNull("ArrayIndexOutOfBoundsException expected", e); } try { fixture.removeElementAt(-1); } catch (ArrayIndexOutOfBoundsException e) { assertNotNull("ArrayIndexOutOfBoundsException expected", e); } }