I am reading Head First: Java, I made it to the middle of chapter 5 (page 106) and one thing caught me off guard; Would I need to save the SimpleDotComTestDrive class in a different Java file, or put it in with the rest. Maybe it explained it, but I can't find it.
So you can have multiple classes declared in a single java source file. but there can be only one public class in the file and the name of the file should be same as that of the public class followed by .java extension. Also note that the class having the public static void main(String args) should be declared as public and rest of the rules mentioned before apply.
Jackson Thurston wrote:Thank you! But to run the test drive, what do I have to do? It obviously won't run on it's own since methods are within the other class. Would I have to put them in a .jar file?
Its enough to have the classes you are using in your classpath- Read the article- HowToSetTheClasspath To know how to make use of the classpath.