title: Efficient methods for Incrementing and Decrementing in the same Loop
body: <p>Suppose some situations exist where you would like to increment and decrement values in the same for loop.  In this set of situations, there are some cases where you can "cheat" this by taking advantage of the nature of the situation -- for example, reversing a string.  </p>
  
  <p>Because of the nature of building strings, we don't really have to manipulate the iterate or add an additional counter:</p>
  
  <pre><code>public static void stringReversal(){
      String str = "Banana";
      String forwardStr = new String();
      String backwardStr = new String();
  
      for(int i = str.length()-1; i &gt;= 0; i--){
          forwardStr = str.charAt(i)+forwardStr;
          backwardStr = backwardStr+str.charAt(i);
      }
  
      System.out.println("Forward String:  "+forwardStr);
      System.out.println("Backward String: "+backwardStr);   
  }
  </code></pre>
  
  <p>However, suppose a different case exists where we just want to print a decremented value, from the initial value to 0, and an incremented value, from 0 to the initial value.</p>
  
  <pre><code>public static void incrementAndDecrement(){
  
     int counter = 0;
  
     for(int i = 10; i &gt;= 0; i--){
         System.out.println(i);
         System.out.println(counter);
         counter++;
     } 
  }
  </code></pre>
  
  <p>This works well enough, but having to create a second counter to increment seems messy.  Are there any mathematical tricks or tricks involving the for loop that could be used that would make <code>counter</code> redundant?</p>