标签:rem pre col family nbsp 相互 iterator 没有 move
Iterator接口的remove方法将会删除上次调用next方法时返回的元素。
next方法和remove方法的调用具有相互依赖性,如果调用remove方法前没有调用next方法是不合法的。
错误使用1:
如果想要删除集合中两个相邻的元素,不能直接这样调用:
1 iterator.remove(); 2 iterator.remove();
必须在中间添加一个next方法的调用。
Java集合使用之next方法与remove方法 | Java集合使用之remove方法使用易错
标签:rem pre col family nbsp 相互 iterator 没有 move
原文地址:https://www.cnblogs.com/KenBaiCaiDeMiao/p/11938633.html