重複する要素を削除したいので、ArrayList を反復処理して、2 つの連続する要素を比較します。(人は比較可能)
ArrayList<Person> persons = getHelper().findAllPersons();
Collections.sort(persons);
ListIterator<Person> it = persons.listIterator();
if(it.hasNext()) {
Person tmp = it.next();
while(it.hasNext()) {
if(tmp.getLastDiscovered() == it.next().getLastDiscovered()) {
getHelper().delete(tmp);
}
tmp = it.next();
}
}
で NoSuchElementException を取得しますtmp = it.next();
while(it.hasNext())
それを防ぐべきではないですか?