I need to compare all the elements of a list 2 to 2 I'm doing in the following way:
List: 1, 2, 3, 4.
Comparison: 1 and 2, 1 and 3, 1 and 4, 2 and 1, 2 and 3 ...
I'm using this way:
Iterator<Policie> p1Iterator = setOfPolicies.iterator();
Iterator<Policie> p2Iterator;
while(p1Iterator.hasNext()) {
p1 = p1Iterator.next();
count++;
p2Iterator = setOfPolicies.iterator();
while(p2Iterator.hasNext()) {
p2 = p2Iterator.next();
}
}
What I wanted to stop doing, is to compare for example: 1 and 2 & 2 and 1. Since it's the same for me. So since I compare the first with all the others, the second with all the others ... The second time for example, I would compare the second with all the front of it, the third with all the front of it, and so on. The problem is that I can not manipulate the positions with the iterator, what could I do?