不过我查了查文档上面是这么写的:
在这个接口中Interface ListIterator<E>
set
void set(E e)
Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither ListIterator.remove nor ListIterator.add have been called after the last call to next or previous.
IllegalStateException - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous.
就是说当你调用了add或者remove方法后就不要再调用set方法了,或者在调用set方法之前调用next方法或者previous方法,将指针移动到相应的位置