Skip to content

Instantly share code, notes, and snippets.

@0xRoch
Created May 1, 2012 15:48
Show Gist options
  • Save 0xRoch/2569024 to your computer and use it in GitHub Desktop.
Save 0xRoch/2569024 to your computer and use it in GitHub Desktop.
protected static void incrementValue(Map<Long, Integer> counters, Long toAdd) {
Integer currValue = counters.get(toAdd);
if (currValue == null)
counters.put(toAdd, 1);
else
counters.put(toAdd, currValue+1);
}
Map<String, Integer> counter = new HashMap<String, Integer>();
for (Item item : aa) {
incrementValue(counter, item.otherattribute.id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment