title: How to remove duplicate elements from arrayList but sum parameter of them?
body: <p>There is object Item with parameters name, code, quantity and expiration date. After I've created arrayList from data (.csv) and got sorted list of Items which duplicates. </p>
  
  <pre><code>Item name Apples, code 5649.0, quantity 1, exp date 2019-07-03.
  
  Item name Oranges, code 124123.0, quantity 3, exp date 2019-12-04.
  
  Item name Oranges, code 124123.0, quantity 4, exp date 2019-12-04.
  
  Item name Peach, code 946598.0, quantity 1, exp date 2017-11-10.
  
  Item name Tomatoes, code 6.5987989764689741E17, quantity 2, exp date 2019-06-20.
  </code></pre>
  
  <p>Object Item has these attributes</p>
  
  <pre class="lang-java prettyprint-override"><code> private String name;
  
   private double code;
  
   private int quantity;
  
   private String expDate;
  </code></pre>
  
  <p>Now I need to remove duplicates but sum the quantity if name, exp date and code is the same (for example to leave one line with Oranges but change quantity to 7 total).</p>
  
  <p>I think about something like that but have no idea what to write inside the loop.</p>
  
  <pre class="lang-java prettyprint-override"><code>
  for(Item a : itemsNeed) {
              for(int b=1; b&lt;itemsNeed.size(); b++) {
                  if(a.getCode()==itemsNeed.get(b).getCode() &amp;&amp; a.getExpDate().equals(itemsNeed.get(b).getExpDate())) {
  
  
                  }
              }
  </code></pre>
  
  <p>This is what I am thinking about but do not know where to move on. Is it correct? Or is there other easier solution?</p>