title: How to create a summary of a list of objects?
body: <p>I think it's a pretty basic question and there should be solutions out there, but I didn't manage to find any. I think I need more help in terminology, on what term I should look up to learn about my problem, but I really appreciate any help.</p>
  
  <p>Anyway, I would like to implement the following:</p>
  
  <p>I have a list of Objects. Each object is in the form of ExampleClass below:</p>
  
  <pre><code>public class ExampleClass {
      private String name;
      private Double firstDouble;
      private Double secondDouble;
  
      + constructor and a bunch of methods
  
  }
  </code></pre>
  
  <p>Basically I have a name variable and a bunch of numbers associated with each instance of ExampleClass. The name variable is not an id, so there may be several ExampleClasses in the list with the same name, all with different numbers associated with them. What I would like to do is to create a "summary" from this list:</p>
  
  <ul>
  <li>Filtering out each instance of ExampleClass with the same name, so in my final list of objects, I do not have two objects with the same name variable.</li>
  <li>I want to make operations with the Double variables of the objects with the same name.</li>
  </ul>
  
  <p>So lets imagine I have the following ExampleClasses in my list:</p>
  
  <pre><code>ExampleClass first = new ExampleClass("apple",1,4);
  ExampleClass second = new ExampleClass("pear",6,12);
  ExampleClass third = new ExampleClass("apple",5,2);
  ExampleClass fourth = new ExampleClass("peach",1,2);
  ExampleClass fifth = new ExampleClass("plum",10,25);
  </code></pre>
  
  <p>In this case I want to remove from the list the first or third element, since they have the same name and I want to make an operation with the numbers, like adding up 1 and 5 and multiplying 4 and 2.</p>
  
  <p>Thanks for any help in advance!</p>
  
  <p>EDIT: I can solve it with a bunch of loops. However, I need my code to be readable and as efficient as it can get. I'm not looking for a brute force solution with nested loops, I'm interested if there is a nice, or nicer solution.</p>