リスト反復子を使用してリストからオブジェクトを削除しようとしています。私はウェブサイトで他の解決策を試しましたが、「スレッド「メイン」java.util.ConcurrentModificationExceptionの例外」というエラーを軽減したものはありません
これが実行されていない私のコードです:
void PatronReturn(String bookName) {
// get to beginning
while(listIterator.hasPrevious()) {
listIterator.previous();
}
while(listIterator.hasNext()){
Book b = listIterator.next();
if (listIterator.next().getBookTitle().equals(bookName)) {
//listIterator.next();
//listIterator.remove();
books.remove(b);
//listIterator.next(); //moves to next so iterator can remove previous ?
//books.remove(listIterator.next());; // TODO see if this is correct
}
}