I\'m doing a project with basic Java for a CS class. The project has a for loop nested inside a while loop.
I am not allowed to use break as a wa
break
This is about perfect code.
for(int i; i < stop; i++) { boolean flag = true; while(flag && condition) { //some action if(shouldIstop) { flag = false; } } }
When you set the flag to false then you will exit from the while, when you will set i to stop then you also will exit from for.