title: How to increment a value in Java Stream?
body: <p>I want to increment value of <code>index</code> with the each iteration by <code>1</code>. Easily to be achieved in the <code>for-loop</code>. The variable <code>image</code> is an array of <code>ImageView</code>.</p>
  
  <p>Here is my <code>for-loop</code>.</p>
  
  <pre><code>for (Map.Entry&lt;String, Item&gt; entry : map.entrySet()) {      
      image[index].setImage(entry.getValue().getImage());
      index++;
  }
  </code></pre>
  
  <p>In order to practise Stream, I have tried to rewrite it to the <code>Stream</code>:</p>
  
  <pre><code>map.entrySet().stream()
      .forEach(e -&gt; item[index++].setImage(e.getValue().getImage()));
  </code></pre>
  
  <p>Causing me the error:</p>
  
  <blockquote>
    <p>error: local variables referenced from a lambda expression must be final or effectively final</p>
  </blockquote>
  
  <p>How to rewrite the <code>Stream</code> incrementing the variable <code>index</code> to be used in?</p>