We know that Java is a reliable programming language because it can catch mistakes early while writing the code and also keeps checking for errors when the program is running. In this blog, we will discuss the type of errors which can occur while doing a code.
public class Laptop{
    public static void main(String[] args){
        System.out.println("hello world");
    }
}
Output: hello world
Here are the possible errors which can occur:
- If the class first letter is given in capital like 'Class' , the error occur *error: class, interface, enum, or record expected Class Laptop{ *
 If the file name doesn't match the public class name like it is given as Home.java instead of Laptop.java, then the error occur as
error: file not found: test.java .If semicolon is removed from the code, then the error will occur as
error: ';' expected
System.out.println("hello world")If double quotes was removed in the arguments, then the error occur as
** error: ')' or ',' expected
System.out.println(hello world)**
** error: not a statement
System.out.println(hello world)**If one of the parentheses ( is removed, then the error occur as
*error: ')' or ',' expected *
** System.out.println("hello world" **If static is missing in the main method, the error occurs
error: package system does not exist
system.out.print("hello world");If wrong case word is given, the error occurs
error: class, interface, enum, or record expectedIf dot(.) is removed, the error occurs
error: class, interface, enum, or record expected
error: ';' expectedIf args is missing in the main method, the error occurs
error: expectedIf double quotes are replaced with single quotes, the error occurs
error: unclosed character literal
    
Top comments (0)