title: How to detect the end of the loop (for each)?
body: <p>Using <code>for(int i = 0; i &lt; str.length; i++)</code> I can easily detect if the loop is at the end. </p>
  
  <p>But I how can I know if I'm using <code>for</code> or <code>for each</code>.</p>
  
  <pre><code>for(String str : arrayString){
  
      if(End of for) //Do something if the end of the loop
  
  }
  </code></pre>
  
  <p>The reason I use <code>for(:)</code> instead of <code>for(;;)</code> is that <code>str</code> is actually a  large Object which I need to use that property for another loop inside that loop. And I don't like using much <code>object.get(index).getProperty</code> It just also for convenience to me in doing the coding. That's why I want to know if the <code>for(:)</code> loop is at the last index.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My interim solution is to assign a <code>int</code> variable that will hold the number of iteration. Then check if the variable is equal to the length of the <code>str.length</code>.</p>