Thursday, 12 September 2013

Java - Why can't I change a variable in a while loop?

Java - Why can't I change a variable in a while loop?

For some reason, whenever I do this:
boolean c = true;
int i = 0;
while (i < 10) {
System.out.println(c);
c = false;
i++;
}
This prints true every single time.

No comments:

Post a Comment