concurrentModificationExeption
in
Programming Questions
•
2 years ago
this works:
- while (i.hasNext()) {
- Song s = (Song) i.next();
- tempSongs.add(s);
- }
this not:
- while (i.hasNext()) {
- Song s = (Song) i.next();
- if(s.count > 1) {
- tempSongs.add(s);
- }
- else {
- String combined = s.artist+s.title;
- songs_hm.remove(combined);
- }
- }
then i suddenly get a concurrentModificationExeption on this line:
Song s = (Song) i.next();
Does that make any sense?
Also what is the proper way of reusing a Iterator for a hashMap?
1