Yes, the rule is that you must have a maximum of one
top-level public class per source file, and that, if you have one, the source file name must be the same as the public class.
A file can have as many top-level package-private classes as you like. However, I think it is bad practice to use this lattitude. I think that, even when classes are package-private,
you should limit yourself to one top-level class per source file, which should be named after the class.
As already mentioned, nested and inner classes have no restriction as to their number, even when public, and do not affect the source file name.