I'm using JCreator and I'm having a problem with my program.
public class Database
{
ArrayList data;
Iterator it;
public Database()
{
data=new ArrayList();
it=data.iterator();
}
public void addPerson (Person p)
{
data.add(p);
}
public void listAll()
{
while(it.hasNext())
System.out.println(it.next());
}
}
What I'm tryin to do is add people to a list and than print em out.
In my driver I say
Database d=new Database();
d.listAll();
INstead of listing the people on the list I get a runtime error that
says
Exception in thread main java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification
(AbstractList.java:444) at java.util.AbstractList$Itr.next
(AbstractList.java:417)
at Database.listAll(Database.java:23)
at DatabaseDriver.main(DatabaseDriver.java:38)
I'm really confused and cud use some feedback