I want to break a while loop of the format below which has an if statement. If that if statement is true, the while loop also must break. Any help would be appreciated.
The break keyword does exactly that. Here is a contrived example:
break
public static void main(String[] args) { int i = 0; while (i++ < 10) { if (i == 5) break; } System.out.println(i); //prints 5 }
If you were actually using nested loops, you would be able to use labels.