Questions And Answers

More Tutorials

Java Errors & Exception

No matter how smart we are, errors are our constant comparisons.
With practice, we keep getting better at finding 2 correcting them.

There are three types of errors in java.

1) Syntax errors
2) Logical errors
3) Runtime errors- also called Exceptions

Syntax Errors

When complex finds something wrong with our program,

it throws a syntax error

int   a = 9  // No semicolon, syntax errors!
a =   a + 3;
d = 4; // Variable not declared, syntax errors

Logical errors

A logical error or a bug occurs when a program
compiles and round but does the wrong thing.

- Message delivered wrongly
- Wrong time of chats being displayed

  • Incorrect redirects!

  • Runtime errors

    Java may sometimes encounter an error while the program is running.
    These are also called Exceptions!
    These are encountered due to circumstances like bad input and (or) resource constraints.
    Ex: User supplies 'S' + 8 to a program that adds 2 numbers.
    Syntax errors and logical errors are encountered by the programmers, whereas Run-time errors are encountered by the users.

    public class cwh_78_errors {
        public static void main(String[] args) {
            int a = 5;
            int b = 9;


    In this page (written and validated by ) you learned about Java Errors & Exception . What's Next? If you are interested in completing Java tutorial, your next topic will be learning about: Java Exceptions and Try Catch Block.

    Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

    Share On:

    Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.