iterator for replacing list members in Java?
You need a ListIterator
instead of an Iterator
(listIterator()
gives you one). Then use the set
method.
ListIterator.set
as returned by List.listIterator()
or List.listIterator(int)
(set
wouldn't make any sense for, say, a Set
iterator.)