posted 16 years ago
In Java, a top-level (not nested or inner) class that is declared public must have a source file whose name is the name of the class, plus ".java". So source for public class Foo must be written in file "Foo.java". It follows from this that there can be a maximum of one top-level public class per source file.
For non-public top-level classes, there is no such restriction. Source for a non-public top-level class can be in a file of any name, plus ".java". There can be any number of non-public top-level classes in a single source file.
However, it is bad practice to make use of this laxity. Non-public top-level classes should be kept to a single class per file, and that file should be named as the class, plus ".java", just like it was a public class.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.