Page 87 - Trackpad_ipro 4.1_Class8
P. 87

The continue Statement

                 Unlike the 'break' statement, the continue statement forces
                 the next iteration  of the loop to take place and skips  the
                 current iteration.
                 For example:

                 public class ContinueStatement
                 {

                    public static void main(String args[])
                     {

                           int i;
                               for(i=1; i<=10; i++)

                               {
                                      if(i==5)

                                      {
                                             System.out.println("Loop is continued");

                                             continue;
                                      }

                                      else
                                      {

                                             System.out.println("The value of i is: " + i);
                                      }

                               }
                     }

                 }
                 In the preceding program, the 'continue' statement stops the execution of the iteration (i == 5)
                 of the 'for' loop. The 'for' loop will be executed normally for all other values of variable 'i'.

                     ERRORS IN JAVA

                 An error is an abnormal condition that can stop the execution of a program. There are three
                 types of errors in Java: syntax errors, runtime errors, and logical errors. Let us learn about
                 these in detail.
                 Syntax Errors

                 The errors that occur due to violation of rules of Java programming language are called
                 syntax errors. These are the most commonly occurring errors while developing programs
                 in Java. Syntax errors are also known as compile time errors. Programs containing syntax
                 errors do not compile. A missing semicolon at the end of a line or adding an extra bracket at
                 the end of a class may produce a syntax error.



                                                             Conditional, Looping and Jumping Statements in Java  85
   82   83   84   85   86   87   88   89   90   91   92