Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. public Map<String, Integer> wordCount(String[] strings) {
  2. Map<String, Integer> map = new HashMap<String, Integer>();
  3.  
  4. for(String s : strings){
  5.  
  6. if(!map.containsKey(s)){
  7. map.put(s, 1);
  8. } else {
  9. int count = map.get(s);
  10. map.put(s, count + 1);
  11. }
  12. }
  13.  
  14.  
  15. return map;
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement