title: java 8 stream group by and summing double
body: <p>I am very new to streams in java 8 so my approach could be wrong. </p>
  
  <p>I have 2 objects as follows</p>
  
  <pre><code>object1 {
      BigDecimal amount;
      Code1 code1;
      Code2 code2;
      Code3 code3;
      String desc;
  }
  
  object2 {
      BigDecimal amount;
      Code1 code1;
      Code2 code2;
      Code3 code3;
  }
  </code></pre>
  
  <p>So I want to collect all object1 where code1 &amp;&amp; code2 &amp;&amp; code3 are same and then sum the amount add it to object2 list.</p>
  
  <p>I do not have a code to do it...I want to write a code that does the job
  I am trying to implement something from <a href="http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/collections/interfaces/map.html</a></p>
  
  <p>Or compute the sum of all salaries by department:</p>
  
  <pre><code>// Compute sum of salaries by department
  Map&lt;Department, Integer&gt; totalByDept = employees.stream()
  .collect(Collectors.groupingBy(Employee::getDepartment,
  Collectors.summingInt(Employee::getSalary)));
  </code></pre>