title: Using string.length() in for loop condition is better than local variable initialised to that, why?
body: <p>I had an impression that in for loop condition, using a variable in place of the method call to string function <code>length()</code> is always better. Though it seems that it is just opposite as analysed by <a href="https://stackoverflow.com/users/1584255/saint-hill">Saint Hill</a> in the following answer</p>
  
  <p><a href="https://stackoverflow.com/a/11876086/6517886">https://stackoverflow.com/a/11876086/6517886</a></p>
  
  <pre><code>for (int i = 0; i &lt; data.length(); i++) {
      ...
  }
  </code></pre>
  
  <p>is faster than </p>
  
  <pre><code>final int len = data.length();
  for (int i = 0; i &lt; len; i++) {
      ...
  }
  </code></pre>
  
  <p>What is the reason?</p>