Break statement inside two while loops

后端 未结 11 1166
时光取名叫无心
时光取名叫无心 2020-12-24 14:00

Let\'s say I have this:

while(a){

  while(b){

   if(b == 10)
     break;
 }
}

Question: Will the break statement take m

11条回答
  •  隐瞒了意图╮
    2020-12-24 14:51

    In your example break statement will take you out of while(b) loop

    while(a) {
    
       while(b) {
    
          if(b == 10) {
             break;
          }
       }  
       // break will take you here.
    }
    

提交回复
热议问题