A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
Why one public class
Pramod P Deore
Joined: Jul 15, 2008
Jul 19, 2008 01:04:00
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
Joined: Aug 16, 2005
Jul 19, 2008 01:34:00
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
Joined: Oct 13, 2005
Jul 19, 2008 01:35:00
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
Source File declaration rule in java
Name of java file with public class
Error message concerning public modifier
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014