René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

JAVA source files

A java source file can contain more than one class. Not more than one of these classes may be declared public.
If the source file contains a public class, then the name of the source file must be the name of this public class with a .java suffix.
The java compiler creates a .class file for each class found in the source file.

Structure of a source file

A java source file consists of three parts: These parts must be in order. That is, the following example is an invalid source file because the import statement occurs before the package statement:
import java.util.*;

package ch.adp-gmbh.some_thing;

class XYZ {
  // ...
}
This implies also that an empty source file is actually a valid source file. Most probably, however, it won't make any sense to anyone.