title: Nested enhanced for loop for One-dimensional arrays
body: <p>I'm trying to compare elements with each other in the array. It would be better to do that with enhanced for loop, but I'm not sure how to do that </p>
  
  <pre><code>for (int i : a4){
      for (int j=0; j&lt;a4.length; j++){ //how to convert this line to enhanced for loop?
          if(a4[i]+1==a4[j]){
              count++;
          } 
      }
  }
  </code></pre>
  
  <p>That's very interesting: when I'm using a regular loop for the first line</p>
  
  <p><code>for(int i=0; i&lt;a4.length; i++)...</code></p>
  
  <p>the program gives the wrong results. 
  what's a mystery? 
  or </p>
  
  <p><code>for(int i=0; i&lt;a4.length; i++)</code> not equal to <code>for (int i : a4)</code>?!</p>