'I'm writing my first ever java program and it's not compiling for a certain reason [duplicate]
This is the code i have tried running
public class main
{
public static void main(String[] args)
{
System.out.println("Hello, world!");
}
}
and it gives me this error:
tempCodeRunnerFile.java:1: error: class main is public, should be declared in a file named main.java public class main
i don't know what wrong tbh i have tried modifying and it looks similar to mee likethe example they gave..
Solution 1:[1]
try naming your file, "main.java"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | HTTRCH |
