Page 88 - iprime_V2.2_class8
P. 88
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.
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.
86 iPRIME (Ver. 2.2)–VIII

