iterator for replacing list members in Java?

后端 未结 3 1887
囚心锁ツ
囚心锁ツ 2021-01-07 16:34

Hmmm... the Java Iterator has a remove() method but not a replace(T replacement) method.

Is there an efficient way to

3条回答
  •  有刺的猬
    2021-01-07 16:51

    You need a ListIterator instead of an Iterator (listIterator() gives you one). Then use the set method.

提交回复
热议问题