title: how to Iterate through an arrayList of object and find duplicates in object properties?
body: <p>I have the following class:</p>
  
  <pre><code>class A {
      ArrayList&lt;String&gt; s = new ArrayList&lt;&gt;();
      double d = Double.MAX_VALUE;
  }
  </code></pre>
  
  <p>I've an arrayList of class A like <code>ArrayList&lt;A&gt; alist = new ArrayList&lt;&gt;();</code>
  In <code>alist</code>I have some elements like followings:</p>
  
  <pre><code>[[b  c]  1.3]
  [[c  d]  0.2]
  [[c  b  o]  0.9]
  [[x  o  j]  1.8]
  [[c  d]  1.7]
  [[b  c  o]  2.2]
  [[f  p  n]  1.1]
  and so on...
  </code></pre>
  
  <p>All I need is to iterate through this <code>alist</code>and check if there any duplicates in String list of <code>class A</code> object. If so then preserve only one element and add others d values with its d value and remove other elements from <code>alist</code>which have the same String list. For example:<br/>from the above list we can see 2nd and 5th elements have duplicate string list so add their values and preserve only one of them with that added value and remove others. Same as, element 3rd and 6th has same String list(string order is not important in inner string list). So for the above list, the expected output will be:</p>
  
  <pre><code>[[b  c]  1.3]
  [[c  d]  1.9]
  [[b  c  o]  3.1]
  [[x  o  j]  1.8]
  [[f  p  n]  1.1]
  </code></pre>
  
  <p>Can anybody help me with this by providing some sample code please? I'm not that good in Java. So please pardon me if I made any mistake!</p>
  
  <p>Thanks!</p>