I'm a COMPLETE beginner at coding. I was looking for the solution to this issue on this forum already but didn't manage to find it.
Right now I am stuck with coding the method removeFirstNote().
Everytime I try to compile I get an error message saying:
java.util.-ConcurrentModificationException
Here's what I've got so far... It needs to be done with a FOR-EACH-loop (school task).
public class Notebook
{
private ArrayList<String> notes;
public Notebook()
{
notes = new ArrayList<String>();
}
public void removeFirstNote(String certainString)
{ int noteNumber = 0;
boolean removed = false;
for (String note : notes){
if(note.contains(certainString) && !removed){
notes.remove(noteNumber);
removed = true;
} else {
noteNumber++;
}
}
}