aspose file tools
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 Elasticsearch in Action this week in the Big Data forum!
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: 14597

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: 41057
Welcome to JavaRanch
It has to do with the compiler finding the class details more quickly. This older thread has more details in.
subject: Why one public class