In the following Java code snippet, I'm having trouble understanding why the loop with while (count++ < 3
) executes when count becomes 3. Shouldn't the condition 3 < 3
be false and the loop terminate? Can someone clarify what's happening here?
public class FeedingSchedule {
public static void main(String[] args) {
boolean keepGoing = true;
int count = 0;
int x = 3;
while (count++ < 3) {
int y = (1 + 2*count) % 3;
switch (y) {
default:
case 0:
x -= 1;
break;
case 1:
x += 5;
}
}
System.out.println(x);
}
}