title: Increment an integer value that is outside a IntStream
body: <p>I am trying to use an <strong>IntStream</strong> to increment an int value that is outside the stream.The point of this method is to find if there are chars on same position that are not equal. The n and word Strings are both same length.</p>
  
  <p>When I try to increment the counter in the scope of forEach it shows me that it should be final or effectively final. Anyone could suggest a better way to do this or a way to increment this counter?</p>
  
  <pre><code>public boolean check(String n,String word){
      int counter=0;
  
      IntStream.range(0, n.length())
          .forEach(z-&gt;{
  
              if(n.charAt(z)!=word.charAt(z)){
              counter++;
              }
          });
      if(counter&gt;1)
          return false;
      else
          return true;
  
  
  } 
  </code></pre>