The structure of a skeletal Java source file is depicted in Figure 2.2. A Java source file can have the following elements that, if present, must be specified in the following order:
Figure 2.2. Java Source File Structure
Note that except for the package and the import statements, all code is encapsulated in classes and interfaces. No such restriction applies to comments and white space. |