title: Using ++ Unary Operator with a Map Get function in Java
body: <p>If an Integer value from within a Map is going to be extracted and placed into a new int variable with one added to it why does the <code>++</code> operator not work with the <code>map.get()</code> function? e.g., <code>int foo = map.get(key)++;</code></p>
  
  <p>To get around this I used</p>
  
  <pre><code>  HashMap&lt;key, Integer&gt; map = new HashMap&lt;key, Integer&gt;();
  
    //Integer values are added in
  
    int foo = map.get(key);
    foo++;
  </code></pre>
  
  <p>But I am curious as to why the prior example is an invalid argument. According to documentation the Map <code>get()</code> function returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.</p>
  
  <p>Granted the value returned is not null, an Integer will be returned, so shouldn't that Integer be able to be incremented before going into foo?</p>