title: Java reverse foreach
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1098117/can-one-do-a-for-each-loop-in-java-in-reverse-order">Can one do a for each loop in java in reverse order?</a>  </p>
  </blockquote>
  
  
  
  <p>For a forward iteration:</p>
  
  <pre><code>for (int i=0; i&lt;pathElements.length; i++){
      T pathElem = pathElements[i];
      .......
  }
  </code></pre>
  
  <p>I can code it as a foreach:</p>
  
  <pre><code>for(T pathElem : pathElements){
      .......
  }
  </code></pre>
  
  <p>Is there a switch so that a foreach could iterate in reverse?</p>
  
  <pre><code>for (int i=pathElements.length-1; i&gt;=0; i--){
      T pathElem = pathElements[i];
      .......
  }
  </code></pre>
  
  <p>Is there a reverse iteration switch in foreach?</p>
  
  <p><em>(If not, don't you think it would be an exciting idea that JDK 8, 9, etc, includes this feature?)</em></p>