Ok , Im trying to add some student object in to a Linked List, But im not allowed to use the .add method of Linked list, So when the user calls the removeStudent Method they enter the sutdents ID number in, Then it checks the List for an Object with that Array
Heres My Code For the Add Method:
public void deleteStudent(int studentID)
{
while (iter.hasNext())
{
Student ob = iter.next();
if (ob.getStudentID() == studentID)
{
iter.remove();
break;
}
}
}
When i run this i get this error:
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:953)
at java.util.LinkedList$ListItr.next(LinkedList.java:886)
at student.Registry.deleteStudent(Registry.java:30)
at student.Registry.main(Registry.java:51)
Java Result: 1