CHAPTER 7: Packages Previous
Previous
Java Language
Java Language
Index
Index
Next
Next

7.3 Compilation Units

CompilationUnit is the goal symbol (S2.1) for the syntactic grammar (S2.3) of Java programs. It is defined by the following productions:


CompilationUnit:

	PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt

ImportDeclarations:

	ImportDeclaration

	ImportDeclarations ImportDeclaration

TypeDeclarations:

	TypeDeclaration

	TypeDeclarations TypeDeclaration

Types declared in different compilation units can depend on each other, circularly. A Java compiler must arrange to compile all such types at the same time.

A compilation unit consists of three parts, each of which is optional:

Every compilation unit automatically and implicitly imports every public type name declared in the predefined package java.lang , so that the names of all those types are available as simple names, as described in S7.5.3.

© 1996 Sun Microsystems, Inc. All rights reserved.