I am trying to understand how "continue" works. I understood the concept of the keyword but when I run different programs, it works differently :-/ Let me show you few examples:
If I run this program :
int j = 0;
int i = 0;
LABEL1: for (; i < 3; i++) {
if (true)
continue;
}
The value of i is gonna be 3. so far so good. Let's add an outer loop :
int j = 0;
int i = 0;
LABEL2: for (; j < 3; j++) {
LABEL1: for (; i < 3; i++) {
if (true)
continue LABEL2;
}
}
The value of i is gonna be ... 0 !! I don't understand why i is not incremented if continue is used with a label that goes to the outer loop. Can somebody explain it why ? Do you have some tricky things like that with break ? or with a do {} while ?
I really appreciate any help you can provide.