I'v noticed that Eclipse creates a new tab when you use its class wizard. Which in turn saves the class code in its own .java file.
My question is:
If I'm writing a program called 'hithere.java' in Eclipses main window and then use the class wizard to generate a new class for my 'hithere.java' program Eclipse will open a new tab into which I can put all my classes and methods. Eclipse will also save this new file as a new'.java' file.
Is this standard practice to have a separate file containing classes as well as the main program file?
Or, is it better to write my classes and methods in my main program file?
Or, perhaps Eclipse has a function to combine the two files together (just guessing).
In general, each class should be in its own *.java file. That's not strictly required (not in all cases, anyway), and there are exceptions, but for the most part, what the class wizard is doing for you is the right way to do things.
Any non-trivial Java application will have multiple Java source files. Some have hundreds, even thousands.
It would be unusual, and confusing, to have "many" files in the same directory--in general (again, for non-trivial applications) the classes are arranged in packages, the layout of which depends on functionality, personal preference, any of many general coding practices, and so on.