Not sure what this error is all about its a new one for me anyway
Prisoners:
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:3
72)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at Prison.ReleasePrisoners(Prison.java:165)
at TestPrison2.main(TestPrison2.java:185)
public void ReleasePrisoners(String id) //search for prisoner by ID
{
System.out.println("Prisoners:");
for (Person x: thePersons)
{
//System.out.println("Found person: " + x.toString());
if (x instanceof Prisoner)
{
Prisoner p = (Prisoner) x;
//System.out.println("Found prisoner: " + p.toString());
//if (p.getPrisonerID() == id )
//p.getPrisonerID()equals(id)
{
if (p.getPrisonerID().equals(id)) //Checks if there is a matching ID within the enetered
{
if(p.getDaysLeft()<7)
{
thePersons.remove(x);
}
else
{
System.out.println("\nThat prisoner cannot be released as he still has "+p.getDaysLeft()+" days left to serve.");
}
}
}
}
else if (x instanceof HRPrisoner)
{
Prisoner p = (Prisoner) x;
//System.out.println("Found prisoner: " + p.toString());
//if (p.getPrisonerID() == id )
//p.getPrisonerID()equals(id)
{
if (p.getPrisonerID().equals(id)) //Checks if there is a matching ID within the enetered
{
if(p.getDaysLeft()<7)
{
thePersons.remove(x);
}
else
{
System.out.println("\nThat prisoner cannot be released as he still has "+p.getDaysLeft()+" days left to serve.");
}
}
}
}
}
}
Thankyou for your help in advance