basically the compiler tells you whats wrong. It says, “class main is public, should be declared in a file named main.java”.
Java has a naming rule, that a class inside a java file needs to match that file name.
Example 1:
Filename -> File.java
inside that file:
public class Main{
...
does violate that rule (class name does not equal the file name)
Example 2:
Filename -> Main.java
inside that file:
public class Main{
...
follows that rule (class name does equal the file name)
Also for beginners:
This is a good quick read for basic code / naming conventions.
https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
0
solved I’m writing my first ever java program and it’s not compiling for a certain reason [duplicate]