title: Why doesn't Java store the value of the conditional in a loop?
body: <p>For example:</p>
  
  <pre><code>for(int i = 0; i &lt; 20 * 40 * 60 * 80; i++){ ... }
  </code></pre>
  
  <p>Compared to: </p>
  
  <pre><code>for(int i = 0; i &lt; 3840000; i++){ ... }
  </code></pre>
  
  <p>The first loop runs much slower than the second (did some time-trials) even though the value of the conditional will never change at any stage throughout the iteration. Sure, with methods this would be different because that value may change (even though it probably shouldn't). I was just wondering why Java doesn't cache / temp that value.</p>
  
  <pre><code>long fact10 = factorial(10);
  for(long n = 0; n &lt; fact10; n++)    vs   for(long n = 0; n &lt; factorial(10); n++)
  </code></pre>