用于替换Java中的列表成员的迭代器? [英] iterator for replacing list members in Java?

查看:49
本文介绍了用于替换Java中的列表成员的迭代器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯... Java Iterator<T>具有remove()方法,但没有replace(T replacement)方法.

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

是否有一种有效的方法来替换列表中的选定项目?我可以使用for循环调用get(i)和set(i),这对ArrayList很好,但对于链接列表却很糟糕.

Is there an efficient way to replace selected items in a List? I can use a for-loop to call get(i) and set(i) which is fine for ArrayList, but would suck for a linked list.

推荐答案

(set对于Set迭代器没有任何意义.)

(set wouldn't make any sense for, say, a Set iterator.)

这篇关于用于替换Java中的列表成员的迭代器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆