how to break out of a while loop in java code example
Example 1: java restart while loop
//use continue keyword
while (true) {
//do stuff
if (condition) continue; //goes to the top of while loop
//do other stuff
}
Example 2: java while loop break
while (true) {
....
if (obj == null) {
break;
}
....
}