I made this stupid mistake again recently! I want to iterate two Sets. One inside another for every element.
Iterator itr1 = set1.iterator();
Iterator itr2 = set2.iterator();
while (itr2.hasNext()) {
...
while (itr1.hasNext()) {
...
}
}
Obviously the inner loop runs only once unless you put the "Iterator itr1 = set1.iterator();" definition inside the outer loop.