1. Why only one public class is allowed in a java file, it shudnt matter as a separate class file is created for each class???
2. Why different name is allowed for the java file for an interface, though the interface name is different and class file is created as per interface name
Can anyone answer this please
Joined: Jan 29, 2003
#1 is a convention to make life easier for the compiler. If you tell it to compile class A and it finds a reference to B it needs to find out if B is up to date. To do that it has to find the souce and class files for B. Putting the source for B in a file called B makes this easy. If you could put any number of public classes in one file, B could be in any file in the package and it would be harder to find.
#2 I'm not following ... the filename has to match the Interface name, just like a Class, right?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi