Errors in Java
These errors will be shown with a red mark in eclipse IDE so that one can easily find and correct them.
Let us look at an example program:
Package com.edureka.error.designerror;
Public class DesignError{
Public Static void Main (String[] args) {
System.out.printIn(“This is Design-time error”);
;
}
}
Here, in the main method, if the m in Main is capital, it will give an error and if the s of the static keyword is capital, it will do the same.
Also, a semi-colon is placed in the print statement in the end as well as below it.
Logical Errors – These are the errors done by programmers. The programs with these errors run but do not produce the desired results. A common example would be getting division of two numbers as output but expected is multiplication of numbers.
Here, if the syntax is correct, but logic is wrong, then its a logical error which will in turn give wrong results. This typically happens in complex programs where the user is unaware of the logic.
Example:
A program has instructions to print numbers 1 to 5 but prints 6.
Got a question for us? Mention them in the comments section and we will get back to you.
Related Posts: