Quantcast
Channel: Reza's Weblog
Viewing all articles
Browse latest Browse all 50

Inner Iterator Loop

$
0
0

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.


Viewing all articles
Browse latest Browse all 50

Trending Articles