Code example for ListIterator

Methods: hasPreviouspreviousIndex

0
    public int previousIndex() { 
        if (list.isEmpty()) {
            throw new NoSuchElementException(
                "There are no elements for this iterator to loop on"); 
        } 
        if (iterator.hasPrevious() == false) {
            return list.size() - 1;
        } else { 
            return iterator.previousIndex();
        } 
    } 
 
    /** 
     * Removes the previously retrieved item from the underlying list. 
     * <p> 
     * This feature is only supported if the underlying list's 
     * {@link List#iterator iterator} method returns an implementation 
     * that supports it. 
     * <p> 
     * This method can only be called after at least one {@link #next} 
     * or {@link #previous} method call. After a removal, the remove