Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Anita Morales   on Sep 20 In Java Category.

  
Question Answered By: Velma Adams   on Sep 20

I would strongly suggest to have these two loops strictly divided
from each other. That means:
1) Have one loop reading the whole file  into the ArrayList.
2) Set up the iterator.
3) Have one loop processing the content of the ArrayList.

It really should be that easy.

Another approach (handy if you insist on having the strings from the
text file processed _and_ at the same time stored in the ArrayList)
would go like this:
Modify your loop such that the string read  from the input  file is
processed immediately and then only stored in the ArrayList; just
NEVER try to append something to an ArrayList which you want to
process out of this same ArrayList at the same time. That can't work.

I hope I made myself clear. If not, please ask again. I'm just too
plain tired to rewrite the loop now, so I leave that up to you.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Concurrent Modification Exception Or get search suggestion and latest updates.