title: Local variable count defined in an enclosing scope must be final or effectively final
body: <p>I am trying to count the number of iterations using Java lambda expressions, but it's throwing a compile time error:</p>
  
  <pre><code>Local variable count defined in an enclosing scope must be final or effectively final
  </code></pre>
  
  <hr>
  
  <pre><code>public static void main(String[] args) {
  
    List&lt;String&gt; names = new ArrayList&lt;String&gt;();
    names.add("Ajeet");
    names.add("Negan");
    names.add("Aditya");
    names.add("Steve");
  
    int count = 0;
  
    names.stream().forEach(s-&gt;
    {
      if(s.length()&gt;6)
          count++;
    });
  }
  </code></pre>