This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why one public class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why one public class " Watch "Why one public class " New topic
Author

Why one public class

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello friends!!!
I want to know why there is only one public class in a .java file?
and Why the name of file must be the name of public class


Life is easy because we write the source code.....
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Because that's just how the Java language was designed. There really isn't any more special reason to it.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37945
    
  22
Welcome to JavaRanch
It has to do with the compiler finding the class details more quickly. This older thread has more details in.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why one public class
 
Similar Threads
Source File declaration rule in java
public class
source file?
Name of java file with public class
Error message concerning public modifier