Common Mistakes and Errors in Java
When we write a Java program we may make small mistakes. Even a small mistake can cause an error in our program. Sometimes the program will not compile and sometimes it will not run properly.
my Home class program I may make the following mistakes.
Missing Semicolon (;)
If I forget to put a semicolon at the end of System.out.println("Hello World"); Java will show a compilation error.
Missing Dot (.)
If I forget the dot in System.out.println() Java will not understand the statement correctly and may show a compilation error.
** Missing Curly Brackets { }**
If I forget the opening or closing curly bracket Java may show an error because the code block is incomplete.
**
Missing Parentheses ( )**
If I forget the parentheses in the main method or print statement Java may show a compilation error.
**
Missing public**
If I remove public from the main method the program may compile but Java may not be able to access the main method to start the program.
** Missing…