DEV Community

Divya Divya
Divya Divya

Posted on

Finding Errors in Java Code

Java Code

public class Home
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}

Output Errors:

1. In Java, public class name and file name must match exactly (including case).

2. In Java, every statement must end with a semicolon (;).

3. Java expects a dot (.) between out and println, but it's missing.

4. Strings must start and end with double quotes "
If one side is missing → unclosed string literal error

5. Java expects array declaration, not function-style brackets.

6. First check last few lines of code — usually missing }.

7. In that mode, Java strictly checks for a properly declared public static main method.

8. It cannot find a package or class named system.

9. Add newline properly (already handled by println, but terminal shows inline sometimes)

10. Java cannot find the correct main method to start execution in class Home.

Top comments (1)

Collapse
 
payilagam_135383b867ea296 profile image
Payilagam

Good Effort!