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.
So to conclude , it is that one java source file must have only one public class with the same name as the name of the source file .
Just a minor change:
So to conclude , it is that one java source file must have only one top-level public class with the same name as the name of the source file .
could you please clarify what it means by " top -level " public class , it means that other public classes are possible in a java source file .
By "Top-level", I meant class which is not an inner class. Inner-classes are the classes as members inside a top-level class. These inner-classes can be public along with their top-level class. Please see the example I quoted in my earlier post where this is done.