wood burning stoves 2.0
The moose likes Beginning Java and the fly likes source code file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "source code file" Watch "source code file" New topic

source code file

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Why is it that there can be only one public class per source code file , whereas there can be more than one non public class.

Is there any reason ...
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Filename = public class name. How are you going to name your file if there are more than one public class ?

[My Blog]
All roads lead to JavaRanch
Darryl Burke

Joined: May 03, 2008
Posts: 5115

More to the point: because the JLS says so.

When packages are stored in a file system (§7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) ...

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: source code file
It's not a secret anymore!