Why? Because it made things simpler for the authors of the first Java compiler. Only public classes are visible outside of their package; therefore, under some circumstances you'll need to easily find the source for a class in another package. If that class is guaranteed to be in a file named after the class, the task becomes trivial.
It also makes it simpler for humans looking at the source code, to find where things are defined. Nowadays, most of us would use a good IDE and this becomes a non-issue. But there were no such nice IDEs for Java in the early days. And even now, sometimes you're looking at code on a server where you don't have an IDE installed. It's nice to just know where the code should be, rather than having to load the code on a different machine before you look at it.
Joined: Sep 26, 2008
If there is a class with 'public' access modifier in one java source file, the java source file must be named as the same as the class name.
Why? I think as Ernest and Mike said, and it is easy for some IDE to match the source file and class file by same name.
So there cannot be two 'public' class in one java source file cause of it cannot be two names for one file.