iterator.remove() 在java中的所有情况下都是稳健的吗?
正如 C++ 中的 iterator.remove() 不是 100% 安全或稳健 java 是否可以通过 iterator.remove() 保证 100% 的鲁棒性?
As in C++ iterator.remove() is not 100% safe or robust
does java guarantees 100% robustness with iterator.remove()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
离开马特的评论(谁真正值得赞扬)
http://java.sun.com/javase/6/docs/api/java/util/Iterator.html#remove%28%29
说:
所以……是的,在某些情况下可能会发生意外/不安全的行为。
Going off of matt's comment (who really deserves the credit)
http://java.sun.com/javase/6/docs/api/java/util/Iterator.html#remove%28%29
says:
So...... yes, there are conditions under which unexpected/unsafe behaviour can occur.
是的,它很强大,因为它是在接口上定义的,因此必须适用于实现它的任何集合。但是,有一些警告来自 Javadoc:
remove()
next( )
remove()
之外,这是不可靠的其他Yes, it's robust in that it's defined on the interface and thus has to work on any collection where it's implemented. However, there are several caveats that come from the Javadoc:
remove()
next()
remove()