DEV Community

mohandass
mohandass

Posted on

The Major Errors In Simple Java Code

Error 1 :

  • Java keywords are case-sensitive. The keyword public must be written in lowercase.

  • If you use Public with a capital P, you'll get an error similar to:

Error 2 :

  • code is missing a semicolon (;) at the end of the System.out.println() statement.

  • In Java, most statements must end with a semicolon (;).

Error 3 :

  • The code has a syntax error in the System.out.println() statement.

  • You used a comma (,) instead of a dot (.).

Error 4 :

  • The Class should be lowercase. Java keywords are case-sensitive.This means Java treats Class and class as completely different words.

  • class - Java keyword used to define a class.

  • Class - Not a Java keyword. Java thinks it's the name of a type or object.

Error 5 :

  • The code is missing the opening curly brace { after the class declaration.

  • After declaring a class, Java expects a class body enclosed in braces

  • Without the {, the compiler doesn't know where the class begins

  • Every opening brace { must have a matching closing brace }.

Top comments (0)