- Feb 8, 2004
- 12,603
- 9
- 81
Iterator<Integer> anIterator = aSet.iterator();
Integer value1;
Integer value2;
Integer value3;
While (anIterator.hasNext())
{
value1 = anIterator.next();
value2 = anIterator.next();
value3 = anIterator.next();
}
Assuming that aSet has a total of 3 Integer elements am I correct in assuming that the while loop will only execute once? If it contained 6 elements the loop would execute twice yes?
Also would there be an infinite loop if the while loop had no .next() in it?
Integer value1;
Integer value2;
Integer value3;
While (anIterator.hasNext())
{
value1 = anIterator.next();
value2 = anIterator.next();
value3 = anIterator.next();
}
Assuming that aSet has a total of 3 Integer elements am I correct in assuming that the while loop will only execute once? If it contained 6 elements the loop would execute twice yes?
Also would there be an infinite loop if the while loop had no .next() in it?