title: Performance wise, is it better to call the length of a given array every time or store the length in a variable and call that variable every time?
body: <p>I call on the length of a given array a lot and I was wondering if it is better to keep calling it numerous times (50+ times currently, but it keeps growing) or is it better to just store the length in an integer and use that integer every time.</p>
  
  <p>If I am unclear in what I am saying, consider the following:</p>
  
  <p>I have a String array:</p>
  
  <pre><code>String[] str = new String[500]; //The length is actually dynamic, not static
  </code></pre>
  
  <p>Of course, I put some values into it, but I call on the length of the string all the time throughout my application:</p>
  
  <pre><code>int a = str.length;
  int b = str.length;
  int c = str.length;
  int d = str.length;
  int e = str.length;
  </code></pre>
  
  <p>and so on...so is it better to do this: (performance wise, don't care about memory as much)</p>
  
  <pre><code>int length = str.length;
      int a = length;
      int b = length;
      int c = length;
      int d = length;
      int e = length;
  </code></pre>
  
  <p>Thanks.</p>