I have some java code for a simple do while loop but it is exhibiting some strange behavior. Sometimes it works but sometimes it exits the loop when it is not supposed to. Can anyone see what I'm doing wrong with this?
I have checked that I am receiving keyboard input correctly and setting the flag to 4 when entered.
I have just put the relevant code.
int flag = 0;
if (flag == 4)
while(flag != 4);