break middle causes only the middle loop (i.e. the j loop) to break. The i loop will continue normally and so i will increment after each iteration of i loop.
If you like our products and services, please help us by posting your review here.
counter is incremented because the inner loop gets to complete a few iterations. See the output given in the explanation with an extra print statement. Observe the values of i, j, and k.
If you like our products and services, please help us by posting your review here.
What I don´t understand is why counter++ is read only when is "break middle",
It shoudn´t be read aswell in the other cases?
for (int k = 0; k < 3; k++) {
if (k - j > 0) {
break middle;
}
counter++;// why the flow of the code is not going here when the condition of
//the if is false?
}
Thank you