Would any one please explain this instruction for me: for (;;)
I have encountered several kinds of these mark (like in ajax code of facebook and in concurrent stuff of Java).
Duplicate elements can be found using two loops. The outer loop will iterate through the array from 0 to length of the array. The outer loop will select an element. The inner loop will be used to compare the selected element with the rest of the elements of the array.
List allows duplicates while Set doesn't allow duplicate elements . All the elements of a Set should be unique if you try to insert the duplicate element in Set it would replace the existing value. List permits any number of null values in its collection while Set permits only one null value in its collection.
An infinite loop.
Each of the three parts of a for loop (for(x; y; z)
) is optional.
So you can do this:
int i = 0;
for (; i < 20; ++i)
and it's perfectly valid, or
for (int i = 0; i < 20;) { ++i; }
or
for (int i = 0; ; ++i) { if (i < 20) { break; } }
and they're all valid.
You can also omit all three parts, with for(;;)
. Then you have a loop that:
so basically an endless loop. It just does what it says in the loop body, again and again
It's an endless loop. For the specificion of the for
statement, see here.
That's an infinite loop, similar to
while(true)
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With