Shervin Asgari Shervin Asgari - 11 months ago 61
Java Question

do while syntax for java

Ages since I have written a do while.

Whats wrong with this do while

int i = 0;
do {
} while(++i == 500);

I only goes once through the loop, and IMO it should iterate 500 times.

Answer Source

You probably meant

while (++i < 500);

instead of

while (++i == 500);