Iterator迭代器导致java.util.NoSuchEle
2022-07-14 本文已影响0人
Jesse4023
多次iterator.next()导致迭代器越界,应该先取出来,再判断
Iterator<DownUrlEntity> iterator = req.iterator();
while (iterator.hasNext()){
if (iterator.next().getId() == null) {
if (!"".equals(iterator.next().getCode()) && !"".equals(iterator.next().getUrl())) {
iterator.next().setCreateTime(new Date());
if (downUrlService.save(iterator.next())) {
iterator.remove();
}
}
}
}