title: Why use a for loop instead of a while loop?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/99164/iterate-with-for-loop-or-while-loop">Iterate with for loop or while loop?</a><br>
    <a href="https://stackoverflow.com/questions/2242646/loops-in-c-for-or-while-which-is-best">Loops in C - for() or while() - which is BEST?</a>  </p>
  </blockquote>
  
  
  
  <p>When should one use a <code>for</code> loop instead of a <code>while</code> loop? </p>
  
  <p>I think the following loops are identical, except for their syntax. If so, then why choose one over the other?</p>
  
  <pre><code>int i;
  for (i = 0; i &lt; arr.length; i++) {
    // do work
  }
  
  int i = 0;
  while (i &lt; arr.length) {
    // do work
    i++;
  }
  </code></pre>