SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top