public ListIterator<E> listIterator(final int index)
public ListIterator<E> listIterator()
  public ListIterator<E> listIterator(final int index)  {    if (index < 0 || index > size())      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"                                          + size());    return new ListIterator<E>()    {      private int knownMod = modCount;      private int position = index;      private int lastReturned = -1;      private int size = size();      // This will get inlined, since it is private.      /**       * Checks for modifications made to the list from       * elsewhere while iteration is in progress.       *       * @throws ConcurrentModificationException if the       *         list has been modified elsewhere.       */      private void checkMod()      {        if (knownMod != modCount)          throw new ConcurrentModificationException();      }      /**       * Tests to see if there are any more objects to       * return.       *       * @return True if the end of the list has not yet been       *         reached.       * @throws ConcurrentModificationException if the       *         list has been modified elsewhere.       */      public boolean hasNext()      {        checkMod();        return position < size;      }      /**       * Tests to see if there are objects prior to the       * current position in the list.       *       * @return True if objects exist prior to the current       *         position of the iterator.       * @throws ConcurrentModificationException if the       *         list has been modified elsewhere.       */      public boolean hasPrevious()      {        checkMod();        return position > 0;      }      /**       * Retrieves the next object from the list.       *       * @return The next object.       * @throws NoSuchElementException if there are no       *         more objects to retrieve.       * @throws ConcurrentModificationException if the       *         list has been modified elsewhere.       */      public E next()      {        checkMod();        if (position == size)          throw new NoSuchElementException();        lastReturned = position;        return get(position++);      }      /**       * Retrieves the previous object from the list.       *       * @return The next object.       * @throws NoSuchElementException if there are no       *         previous objects to retrieve.       * @throws ConcurrentModificationException if the       *         list has been modified elsewhere.       */      public E previous()      {        checkMod();        if (position == 0)          throw new NoSuchElementException();        lastReturned = --position;        return get(lastReturned);      }      /**       * Returns the index of the next element in the       * list, which will be retrieved by <code>next()</code>       *       * @return The index of the next element.       * @throws ConcurrentModificationException if the list       *         has been modified elsewhere.       */      public int nextIndex()      {        checkMod();        return position;      }      /**       * Returns the index of the previous element in the       * list, which will be retrieved by <code>previous()</code>       *       * @return The index of the previous element.       * @throws ConcurrentModificationException if the list       *         has been modified elsewhere.       */      public int previousIndex()      {        checkMod();        return position - 1;      }     /**      * Removes the last object retrieved by <code>next()</code>      * or <code>previous()</code> from the list, if the list      * supports object removal.      *      * @throws IllegalStateException if the iterator is positioned      *         before the start of the list or the last object has already      *         been removed.      * @throws UnsupportedOperationException if the list does      *         not support removing elements.      * @throws ConcurrentModificationException if the list      *         has been modified elsewhere.      */      public void remove()      {        checkMod();        if (lastReturned < 0)          throw new IllegalStateException();        AbstractList.this.remove(lastReturned);        size--;        position = lastReturned;        lastReturned = -1;        knownMod = modCount;      }     /**      * Replaces the last object retrieved by <code>next()</code>      * or <code>previous</code> with o, if the list supports object      * replacement and an add or remove operation has not already      * been performed.      *      * @throws IllegalStateException if the iterator is positioned      *         before the start of the list or the last object has already      *         been removed.      * @throws UnsupportedOperationException if the list doesn't support      *         the addition or removal of elements.      * @throws ClassCastException if the type of o is not a valid type      *         for this list.      * @throws IllegalArgumentException if something else related to o      *         prevents its addition.      * @throws ConcurrentModificationException if the list      *         has been modified elsewhere.      */      public void set(E o)      {        checkMod();        if (lastReturned < 0)          throw new IllegalStateException();        AbstractList.this.set(lastReturned, o);      }      /**       * Adds the supplied object before the element that would be returned       * by a call to <code>next()</code>, if the list supports addition.       *        * @param o The object to add to the list.       * @throws UnsupportedOperationException if the list doesn't support       *         the addition of new elements.       * @throws ClassCastException if the type of o is not a valid type       *         for this list.       * @throws IllegalArgumentException if something else related to o       *         prevents its addition.       * @throws ConcurrentModificationException if the list       *         has been modified elsewhere.       */      public void add(E o)      {        checkMod();        AbstractList.this.add(position++, o);        size++;        lastReturned = -1;        knownMod = modCount;      }    };  }