Skip to content

Instantly share code, notes, and snippets.

@mchirico
Created January 29, 2013 15:53
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 mchirico/4665270 to your computer and use it in GitHub Desktop.
Save mchirico/4665270 to your computer and use it in GitHub Desktop.
Example iterator with HashMap
public void pr(ConcurrentHashMap<String, String[][]> hmap) {
Iterator itr = hmap.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry pairs = (Map.Entry) itr.next();
System.out.println("key= " + pairs.getKey());
pr((String[][]) pairs.getValue());
// itr.remove(); // avoids a ConcurrentModificationException
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment