I may be wrong, but could have something to do with classloaders. If the program needs the specification/implementation of class X, where should it look for if not in file name X.class ? Should the JVM look in *every* .class file to find it ?
----------------- it is easy for the class loader to load and initialize the particular class. as the classname and filename is same the job becomes easier. also it help the compiler too in the same way... ----------------- vijay [ October 22, 2008: Message edited by: V Vijay Veeraraghavan ]
It has nothing to do with class loading, since *.java files don't contain loadable classes!
It has everything to do with making the command-line compiler's life easier. If class A refers to class B, and class B is stored in a file named B.java, then when A is being compiled, the compiler can find the source for class B automatically. If it were stored in a file by any other name, then the compiler would have to search every *.java file it could find, which is obviously not so efficient.