Skip to content

Instantly share code, notes, and snippets.

@anderson-martins
Created August 16, 2012 14:17
Show Gist options
  • Save anderson-martins/3370404 to your computer and use it in GitHub Desktop.
Save anderson-martins/3370404 to your computer and use it in GitHub Desktop.
Iteration over HashTable
Map<Integer, String> map = ...
Iterator<Map.Entry<Integer, String>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, String> entry = it.next();
// Remove entry if key is null or equals 0.
if (entry.getKey() == null || entry.getKey() == 0) {
it.remove();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment