can someone pls tell me why we always have to save the prog file with the same name as the main class.if i don't i get a strange error message.
Printable View
can someone pls tell me why we always have to save the prog file with the same name as the main class.if i don't i get a strange error message.
What is the "prog file"?
I think he means why do you have to save the class in a file with the same name.
Because of Java's class lookup rules. Java computes the name of the file storing a class from the class name. That's the short version. For the long version, search this forum for posts by me containing "classpath" and "class loader", or browse the web.