title: Group by and sum operation on a String array
body: <p>I have a <code>String[]</code> <code>dataValues</code> as below:</p>
  
  <pre><code>ONE:9
  TWO:23
  THREE:14
  FOUR:132
  ONE:255
  TWO:727
  FIVE:3
  THREE:196
  FOUR:1843
  ONE:330
  TWO:336
  THREE:190
  FOUR:3664
  </code></pre>
  
  <p>I want to total the values of <code>ONE</code>, <code>TWO</code>, <code>THREE</code>, <code>FOUR</code>, <code>FIVE</code>.</p>
  
  <p>So I created a <code>HashMap</code> for the same:</p>
  
  <pre><code>Map&lt;String, Integer&gt; totals = new HashMap&lt;String, Integer&gt;();
  for(String dataValue : dataValues){
      String[] keyVal = dataValue.split(":");
        totals.put(keyVal[0], totals.get(keyVal[0]).intValue() + Integer.parseInt(keyVal[1]));                            
  }
  </code></pre>
  
  <p>But above code will <strong>obviously throw</strong> below exception if the key is not already existing in the map:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  </code></pre>
  
  <p>What is the best way to get the totals in my usecase above?</p>