I just began learning Java. My friend who knows much more than me has sent me a few different files which I try to run but it gives me an error. I appologize as I don’t have any of the classes on this computer and can’t generate the errors right now but it appears as though the errors are due to the naming of my project as something different than a class in the file. As soon as I try renaming things it seems to fall apart and cause more problems. I know this is a total noob question but could someone explain the naming convention of the main class, project name, etc so I can run a project with multiple classes?
Thank you.
I just began learning Java. My friend who knows much more than me has
Share
Files with names ending in
.java(the ones that contain your actual code) are called source files. Each source file is allowed to contain onepublicclass. If a source file does contain apublicclass, then its filename has to match the class name.For example, if your class contains
then the filename has to be
HelloWorld.java.Each source file is also allowed to contain any number of non-
publicclasses. Those classes do not have anything to do with the filename.Also, you mentioned the name of your project. There is no such thing as a project in Java. Projects are a concept used by programs that help you write Java code (these are called IDEs), like Eclipse and NetBeans. Are you using one of those programs?