Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Java program question?

  Asked By: Thomas    Date: Aug 02    Category: Java    Views: 626
  

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

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Java program question? Or get search suggestion and latest updates.




Tagged: