Page 88 - TP_iPlus_V2.1_Class8
P. 88

}
                                       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 the variable i.


                   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 violating the rules of the 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.
                  For example:

                  public class SyntaxError{
                         public static void main(String args[])
                         {
                                int a = 100;
                                int b = 200;
                                int c = a * b

                                System.out.println(c);
                         }
                  }
                  }

                  In the preceding program, the statement "int c = a * b" produces an error because we have not
                  added the semicolon at the end of the line. We have also added an extra bracket at the end of
                  the class. So, the compiler shows an error message for the same.
                  Runtime Errors

                  Runtime errors are those that occur at runtime. These errors interrupt the program execution
                  abnormally. When a runtime error occurs, the program terminates its execution even if it
                  has compiled successfully. Runtime errors are also known as exceptions. One of the most
                  commonly occurring runtime errors is the division by zero error. It occurs when we divide a
                  number by zero.



                    86
                         iPlus (Ver. 2.1)-VIII
   83   84   85   86   87   88   89   90   91   92   93