glomelurus.com: A Geek's Story
Anything that's happening here.
Pages
(Move to ...)
Home
Some Histories
Favorite Quotes
▼
Saturday
ConcurrentModificationException
This code will always throw ConcurrentModificationException:
for (Person person: group) {
group.remove(person);
}
Because:
You cannot remove an object from a collection while iterating through it.
To solve this problem, use the
clear()
method to remove all objects of a collection.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment