Best Practice in `For` loop in java
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6093537/for-loop-optimization">for loop optimization</a>  </p>
</blockquote>



<p>In java i have a block of code:</p>

<pre><code>List e = {element1, element2, ...., elementn};
for(int i = 0; i &lt; e.size(); i++){//Do something in here
};
</code></pre>

<p>and another block:</p>

<pre><code>List e = {element1, element2, ...., elementn};
int listSize = e.size();
for(int i = 0; i &lt; listSize; i++){//Do something in here
};
</code></pre>

<p>I think that the second block is better, because in the first block, if <code>i++</code>, we have to calculate <code>e.size()</code> one more times to compare the condition in the <code>for</code> loop. Is it right or wrong?
And comparing the two block above, what is the best practice for writting for? And why? </p>
