title: Why does this loop require a decrement?
body: <pre><code>class Testing {
   public static void main(String args[]) {
  
     int e;
     int result;
  
     for(int i = 0; i &lt; 10; i++) {
       result = 1;
       e = i;
       while(e &gt; 0) {
         result *= 2;
          e--;
       }
  
       System.out.println("2 to the " + i + " power is " + result);
     }
   }
  </code></pre>
  
  <p>The above code tests the integer power of 2 from 0 to 9. I'm confused as to why <code>e--;</code> is required in the while loop? Removing it causes an infinite loop error, but why? Wouldn't the code automatically break on the 9th time considering <code>e = i</code> and <code>i</code> already having a limit to be less than 10?</p>
  
  <p>I would appreciate a simple/beginner explanation.</p>