I want only the while loop to start over if the if condition inside is true. In my book this is achieved with breaking the loop, to let it start over. Problem with this code is: The break does nothing but stopping the while loop. If the if condition is true, nothing gets repeated. The method returns the value of x and it is over. How can I get the while loop repeat if the if condition is met, in this example? Thank you :)
public int example() {
for() {
if() {
//code
}else{
z=0;
while (z==0) {
//code
if() {
//code
break;
}else{
z=1;
}
}
}
}
return x;
}
Aucun commentaire:
Enregistrer un commentaire