Page 209 - CA_Blue( J )_Class9
P. 209

14                  if(n%i==0)
                  15                  {   System.out.print(i+" ");

                  16                  }
                  17                  i++;

                  18              }while(i<=n);
                  19          }

                  20      }

                 You will get the following output:












                 9.3.6 Jump Statements
                 Jump statements transfer the program control to another part of the program which depends on the given condition.

                 In Java we have the following three jump statements:

                                                           Jump Statements






                                        break                  continue                 return


                 Let us study them in detail:

                 break
                 This statement is used to exit from the loop. As soon as the break statement in a loop executes, the execution will
                 be transferred to the next statement immediately outside the loop. This means, the statements after the break
                 statement will not be executed. "break” statement can be applied with all the different types of loops.

                 Syntax:
                    for (initialization; condition for testing; increment or decrement)
                    {
                        if(condition)
                            {
                                  break;
                            }
                        Statements inside loop;
                    }
                    1st statement after loop;







                                                                                       Iterative Constructs in Java  207
   204   205   206   207   208   209   210   211   212   213   214