Header Ads

  • Breaking Now

    When do you use 'continue' and 'break' statements?

    When one wants to complete the iteration of a loop prematurely then 'continue' statement is used.
    While the 'break' statement is used to exit the entire loop whenever encountered.

    1 comment:

    1. If you have nested loops/if statements, how far out will 'continue' and 'break' operate? For example:

      while(condition1){

      while(condition2){

      if(condition3){
      continue;
      }
      else{
      break;
      }

      }

      }

      ReplyDelete

    Post Top Ad

    Post Bottom Ad