-4

Is there any case that the program will skip continue? This is the code:

     while(/*something*/){
           if(/*something*/){
                while(true) {
                    //do something

                }
                System.out.print("Hello");
                continue;
            }
//do something2
    }

I would put my whole code but it's very long to trace. i want to know if there is a known cases that the continue will be skipped. My program enters the big while-loop, enters if-statement but sometimes it doesn't continue and skip to //do something2 . There is no breaks or anything like that.

onlyforthis
  • 444
  • 1
  • 5
  • 21

1 Answers1

3

while(true) will always continue if the end of the loop is reached. You can stop the while loop by using break:

while(true) {
    //doSomething

    if (myCondition) 
        break;
}

If myCondition is true, you will break out of the while loop.

Marv
  • 3,517
  • 2
  • 22
  • 47