Skip to content

Instantly share code, notes, and snippets.

@spitz-dan-l
Created May 13, 2015 13:47
Show Gist options
  • Save spitz-dan-l/e39bdc4bd4b5704971d6 to your computer and use it in GitHub Desktop.
Save spitz-dan-l/e39bdc4bd4b5704971d6 to your computer and use it in GitHub Desktop.
public void updateWordCount(HashMap<String, Integer> counts, String wordToUpdate){
if (counts.containsKey(wordToUpdate)) {
int current_count = counts.get(wordToUpdate);
counts.put(wordToUpdate, current_count++);
} else {
counts.put(wordToUpdate, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment