Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobster1234/5086686 to your computer and use it in GitHub Desktop.
Save lobster1234/5086686 to your computer and use it in GitHub Desktop.
ConcurrentModificationException - How to get one.
public class Map {
public static void main(String[] args) {
HashMap<Integer,Long> map = new HashMap<Integer,Long>();
for(int i = 0;i<100;i++){
map.put(i,System.nanoTime());
}
Iterator<Integer> it = map.keySet().iterator();
while(it.hasNext()){
map.remove(it.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment