wood burning stoves
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why one public class " Watch "Why one public class " New topic

Why one public class

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 632

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: 15081

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 8 API documentation
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46328
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
It's not a secret anymore!