In the following code, does the break statement break out of the if statement only or out of the for loop too?
I need it to break out of the loop too.
for (int i = 0; i < 5; i++) {
if (i == temp)
// do something
else {
temp = i;
break;
}
}
That would break out of the for loop. In fact
breakonly makes sense when talking aboutloops, since they break from theloopentirely, whilecontinueonly goes to the nextiteration.