r/javahelp • u/casual_microwave • Sep 23 '19
Solved Java compiler keeps telling me that my public class name needs to match my file name, BUT IT DOES. Why is it doing this?
RunsPrinter.java
public class RunsPrinter {
FUCKIN ERROR
2
u/bobphorous Sep 23 '19
Because there is an error somewhere. The compiler just gives you what it sees. Even though it seems like it sometimes, the compiler is not there to frustrate you.
Screenshot the filename, the classname and the error. The program may be having an error that is causing this error. One thing you can try is to create a new file and copy the classname to the filename and copy paste the contents into the file and replace the one giving the error. If that doesn't fix the problem, you could try using an IDE like intellij. They tend to be fairly helpful with identifying errors and autocomplete.
0
u/casual_microwave Sep 23 '19
Yeah idk why but I wrote more code and the error went away.
2
u/wildjokers Sep 23 '19
You had a syntax error that was causing the compiler to see other characters as part of your class name. It is very important to post the whole file when something like that happens. The compiler won't lie to you.
4
u/Lvl20Rogue Sep 23 '19
Is that the whole file?