Class is public, should be declared in a file named in JAVA

Class is public, should be declared in a file named in JAVA

In general in a java file named for example YamiCode.java we can have multiple classes or interfaces but it can only contains one or zero public class. If we have a public class the class name should be equal to the file name (YamiCode).

//YamiCode.java

//The following line will throw a compilation error
public class SomethingElse

//Fixing The error
public class YamiCode {

    public static void main(String args[]) {
        //...
    }

}