title: How to increment a "number" in a Java 8 lambda expression in a loop?
body: <p>I have the following problem. I have an integer position which starts at 1 and increments every time a specific person from a txt is found at a specific position in an xml. If I use the classic iteration with the foreach <code>for (PersonMatchInfo pmi : personMatchInfo)</code> it works, but my senior asked me to do with the Java 8 <code>foreach</code> and this type of iteration works only with final variables. How can I increment the integer in the new Java 8 loop? Thank you.</p>
  
  <pre><code>int position = 1;
  personMatchInfo.forEach(pmi -&gt;{
  
                      if (!stopwatch1.isStarted()) {
                          stopwatch1.start();
                      } else if (stopwatch1.isStarted()) {
  
                      }
  
                      if (pmi.getPersonName().equals(e.getValue())) {
  
                          positionMap.put(position, positionMap.get(position) + 1);
                          break;
  
                      } else {
  
                          position++;
                      }
                  });
  </code></pre>