File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is empty file is valid java source file?

 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read in one book,that is Is empty source file a valid java source file?The answer they gave is yes.I could not get the right explanation.
i don'y know what they mean.withot interface,class,package,import how can a file will be a valid source file?
Its confusing me.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you browse to JLS 7.3: Compilation Units, you will see that a compilation unit (i.e., a Java source file) is composed of three high level elements, called PackageDeclaration, ImportDeclarations, and TypeDeclarations. All of them are optional, which clearly means that an empty compulation unit is a valid java file.
I hope this clears your doubts.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic