The Java® Language Specification, Java SE 7 Edition, Fourth Edition
by James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Alex Buckley
7.3. Compilation Units
CompilationUnit is the goal symbol (§2.1) for the syntactic grammar (§2.3) of Java programs. It is defined by the following productions:
CompilationUnit: PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsoptImportDeclarations: ImportDeclaration ImportDeclarations ImportDeclarationTypeDeclarations: TypeDeclaration TypeDeclarations TypeDeclaration
A compilation unit consists of three parts, each of which is optional:
• A package declaration (§7.4), giving the fully qualified name (§6.7) of the package to which the compilation unit belongs.
A compilation unit that has no package declaration is part of an unnamed package (§7.4.2).
• import declarations (§7.5) that allow types from other packages and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access