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
If you are not allowed to use break, then it makes sense not to use return as well, since every loop with break can be rewritten as a loop with return (by outsourcing it into a separate function).
From a non-homework point of view, break (and return) are very useful language features which are usually not considered bad style (of course, every language construct can be abused to write bad code).
In your homework scenario, however, I guess it would defeat the point of the homework to just "workaround" the missing break by using return. You should think of an alternative way to solve your task.
I tried to put a boolean operator in the while loop that controls the for loop but that doesn't control what goes on inside the for loop until the for loop gets to the end.
That's true, but, by using the if statement, you can also execute/not execute code inside the loop depending on your boolean.