The structure of a skeletal Java source file is depicted in Figure 4.1. A Java source file can have the following elements that, if present, must be specified in the following order:
1. An optional
package declaration to specify a package name. Packages are discussed in §4.2.
2. Zero or more
import declarations. Since
import declarations introduce type or static member names in the source code, they must be placed before any type declarations. Both type and static
import declarations are discussed in §4.2.
3. Any number of top-level type declarations. Class, enum, and interface declarations are ...