Remove duplicate string from ArrayList
<p>I have an <code>ArrayList</code> of <code>Strings</code> with duplicate elements. Every 3 rows make an entity:</p>

<pre>
2
550111.55
1, 3
</pre>    

<pre>
3
550111.55
1, 2, 3
</pre>    

<pre>
2
155.55
1, 2
</pre>

<pre>
3
550111.55
2, 3, 1
</pre>    

<pre>
2
155.55
2, 1
</pre>    

<pre>
2
550111.55
3, 1
</pre>    

<pre>
3
550111.55
3, 1, 2
</pre>

<p>All the elements are <code>Strings</code>. The first number says the number of participants, the second says the value, and the third which elements make it up.
So I have duplicates like </p>

<pre>
3
550111.55
3, 1, 2
</pre>

<p>and</p>

<pre>
3
550111.55
1, 2, 3
</pre>

<p>and </p>

<pre>
3
550111.55
2, 3, 1
</pre>

<p>The number of elements says the number of duplicates, so I must remove all the duplicates, in this case, delete all but one instance, for example:</p>

<pre>
3
550111.55
2, 3, 1
</pre>

<p>I am trying to do it like this :</p>

<pre><code>ArrayList&lt;String&gt; lista_rezultata1=new ArrayList&lt;String&gt;();
lista_rezultata1=lista_rezultata;
//set to count to 3 in arraylist since data I need to split and evaluate are always on the third place
int number1=0;
int number2=0;
String[] part1=null;
String[] part2=null;
int removefromlist=0;
for (int i = 0; i &lt; lista_rezultata.size(); i++) {
    if(number1==3)number1=0;
    if(number1==2)//If it is a third element it is the one with "," that I split
    {
        part1=lista_rezultata.get(i).toString().split(",");
    }

    for (int j = 0; j &lt; lista_rezultata1.size(); j++) {
        if(number2==3)number2=0; 

        if(number2==2 &amp;&amp; i!=j &amp;&amp; number1==2)//If it is a third element it is the one with "," that I split, first must already be splited
        {
            part2=lista_rezultata1.get(j).toString().split(",");

            for (int k = 0; k &lt; part1.length; k++) {
                for (int l = 0; l &lt; part2.length; l++) {
                    if(part1.length==part2.length)   //if they have the same number of elements
                    { 
                        if(part2[l].equals(part1[j]))
                        {
                            .....some code
                        }
                    }
                }
            }
        }

        number2=number2+1;   
    }
    number1=number1+1; 
}
</code></pre>

<p>So I am hoping there is a better way ...</p>
