title: Confused on math
body: <pre><code>public static int Alpha(){
  
      HashMap&lt;Integer, Double&gt; map = new HashMap&lt;Integer, Double&gt;();
      map.put(1,5.5);
      map.put(67,1.4);
      map.put(9,7.8);
      map.put(24,6.4);
  
  
      int ans = -1;
      double best = 0.0;
       for(int i : map.keySet()){
      if(map.get(i) &gt; best){
       best = map.get(i);
       ans = i;
       }
       }
       return ans;
  
      }   
  </code></pre>
  
  <p>I don't understand why this returns 9. My logic is that the For-each loop goes through each key and with the If-statement it says: If for any one of these keys if it's greater than 0.0 set best equal to that number? The first number it sees in the key set that is greater than 0.0 is 1 so shouldn't best be 1?</p>
  
  <p>I also don't understand the ans = i  line.  What does that do?</p>
  
  <p>A piece by piece explanation of this <em>specific</em> code would be appreciated.</p>