File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Empty java file

 
mahesh ogale
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why empty java file gets compiled correctly if it is the requirement that filename should match class name which contains main method?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's required that any public outer class defined in a source file matches the name of the file.
That the main method should be in a public class defined in a source file of the same name is nothing to do with whether every source file should have a matching public class defined, or any class defined at all. Though, if the source file doesn't define any classes, then it's not much use really.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic