title: Lambda Expression to find sum
body: <p>I have a class as below:</p>
  
  <pre><code>public class Class2 {
  
  private final Integer x;
  
  private final Integer y;
  
  public Class2(final Integer x, Integer y) {
      this.x = x;
      this.y = y;
  }
  
  public Integer getX() {
      return x;
  }
  
  public Integer getY() {
      return y;
  }
  
  }
  </code></pre>
  
  <p>I have a Map object like below:</p>
  
  <p><code>Map&lt;MyEnum , List&lt;Class2&gt;&gt; mapX</code></p>
  
  <p>I want to find the sum of x &amp; y members  of the Class2 instances in the List instance which is the value item in the above map. I want to use lambda expressions</p>
  
  <p>I have come up with the following incomplete lambda. Thanks in advance.</p>
  
  <pre><code>        mapX.entrySet().forEach(entry -&gt; {
              System.out.println("MapX-Key : " + entry.getKey() + "\nMapX-Value : "
                      + entry.getValue().stream().collect(Collectors.summingInt(???)));
          });
  </code></pre>