title: Variable used in Lambda should be final or effective final while calculating sum?
body: <p>I have a map which contains a map.
  Map>
  For all entries in the map, I want to calculate the sum of a particular key. </p>
  
  <p>For example my map is something like this:</p>
  
  <pre><code>Key1    Key2    Value
  A       Z       10.10
  B       Z       40.10
  C       Y       20.10
  </code></pre>
  
  <p>I want to calculate basically the sum of all the  key2 which is equal to B. So in this case I want to get 50.20 as Key1 -C does not have key2 Z</p>
  
  <p>I am trying to do this using Java 8. I am not sure how I should collect the sum. </p>
  
  <pre><code>double sum = 0;
  myMap.forEach((key1, key2) -&gt; {
      sum += key2.get("Z");
  });
  </code></pre>
  
  <p>But then I get an error saying that value inside lambda should be a final. </p>