title: java compiler optimization
body: <p>Is the Java compiler smart enough to optimize loop below, by extracting the</p>
  
  <pre><code>Double average = new Double( totalTime / callCount ); 
  </code></pre>
  
  <p>out of the for loop?</p>
  
  <pre><code>public double computeSD( Set values, int callCount, long totalTime ) {
    double diffs = 0.0d; 
    for( Iterator i=values.iterator(); i.hasNext(); ) {
      double value = ( ( Double )i.next() ).doubleValue(); 
      Double average = new Double( totalTime / callCount ); 
      diffs += ( value – average.doubleValue() ) * ( value – average.doubleValue() );
    } 
    double variance = diffs / callCount;
    return Math.sqrt( variance );
  }
  </code></pre>