title: null pointer exception when retrieving from HashMap even though containsKey() returns true
body: <p>I've been developing an Android guitar app, and currently I'm having some problems with <code>HashMap</code>.</p>
  
  <p>To sum it up, I get a <strong>nullpointer exception</strong> when I try to retrieve a value from a <code>HashMap</code> with <code>get(key)</code> despite <code>containsKey(key)</code> returning <code>true</code> for that key.</p>
  
  <p>Specifically, I have an instance <code>_currentPreset</code> of a class, which has a <code>HashMap</code> called <code>_maxCoordRange</code>, which is initialized in the class like this:   </p>
  
  <pre><code>private Map&lt;String, Float&gt; _maxCoordRange = new HashMap&lt;String, Float&gt;();
  </code></pre>
  
  <p>This parameter is not modified in the constructors of the class. Instead, it can only be modified by the following method:</p>
  
  <pre><code>public void setMaxCoordRange(String parName, float value) {
      _maxCoordRange.put(parName, value);
  }
  </code></pre>
  
  <p>and accessed by:</p>
  
  <pre><code>public float getMaxCoordRange(String parName) {
      return _maxCoordRange.get(parName);
  }   
  </code></pre>
  
  <p>Once I've created the <code>_currentPreset</code> instance, I set some values to the <code>_maxCoordRange</code> map like this:</p>
  
  <pre><code>for (int i = 0; i &lt; _currentPreset.getCoordiates().size(); i++) {       
      _currentPreset.setMaxCoordRange(_currentPreset.getParNames().get(i), 0.75f);
  }
  </code></pre>
  
  <p>In other parts of the code I do the following:</p>
  
  <pre><code>if(_currentPreset.getMaxCoordRange().containsKey(pareterName)){
      cord.setMaxValueCoord(_currentPreset.getMaxCoordRange(pareterName));
  }
  </code></pre>
  
  <p>Here is the odd part. I get a nullpointer exeption when I try to retrieve the value corresponding to the <code>pareterName</code> from the <code>HashMap</code> with <code>getMaxCoordRange</code>, despite <code>containsKey(key)</code> returning true.</p>
  
  <p>I did some debugging and I found something rather strange to me.
  When I finished putting the values in the map, in the expressions tag (when in debugging mode in eclipse), the table looks like this:</p>
  
  <pre><code>table   HashMap$HashMapEntry[16]  (id=829660787832) 
  [0] null    
  [1] null    
  [2] null    
  [3] null    
  [4] null    
  [5] null    
  [6] null    
  [7] null    
  [8] HashMap$HashMapEntry  (id=829660788568) 
  [9] HashMap$HashMapEntry  (id=829660786456) 
  [10]    HashMap$HashMapEntry  (id=829660787920) 
  [11]    HashMap$HashMapEntry  (id=829660788376) 
  [12]    HashMap$HashMapEntry  (id=829660787448) 
  [13]    HashMap$HashMapEntry  (id=829660787640) 
  [14]    HashMap$HashMapEntry  (id=829660786840) 
      hash    789729998   
      key "Test Par3" (id=829660737240)   
      next    HashMap$HashMapEntry  (id=829660786144) 
          hash    789729854   
          key "Test Par1" (id=829660736816)   
          next    null    
          value   Float  (id=829660786088)    
      value   Float  (id=829660786824)    
  [15]    HashMap$HashMapEntry  (id=829660787088) 
      hash    789729999   
      key "Test Par4" (id=829660737376)   
      next    HashMap$HashMapEntry  (id=829660786648) 
          hash    789729855   
          key "Test Par2" (id=829660737104)   
          next    null    
          value   Float  (id=829660786632)    
      value   Float  (id=829660787016)    
  </code></pre>
  
  <p>There should be 10 values, and there are, but 2 of them are in the <code>next</code> field of elements 14 and 15. I read that this is the way the hashMaps arrange the data in order to be more efficient, but couldn't it be the reason why I'm not able to retrieve the values?</p>
  
  <p>Sorry about giving so much information, but I don't really know where the problem is. I've used HashMaps before and I didn't have this problem.</p>
  
  <p>Any ideas on how can i solve this and finally get my values from the map?</p>