Page 85 - iPlus_Ver_2.0_class_8
P. 85
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. For example,
public class RuntimeError{
public static void main(String args[])
{
int a = 100;
83
Conditional, Looping and Jumping Statements in Java

