This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Some basic questions , i dont know the answer for Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Some basic questions , i dont know the answer for" Watch "Some basic questions , i dont know the answer for" New topic
Author

Some basic questions , i dont know the answer for

Sona Makheeja
Greenhorn

Joined: Oct 25, 2004
Posts: 11
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
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
#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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Some basic questions , i dont know the answer for
 
Similar Threads
bean class doubt
Bean class question
Scope of jsp:useBean
Naming a java file?
Multiple Inheritance in java