This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Top level class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Top level class?" Watch "Top level class?" New topic
Author

Top level class?

Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
It is said that a java source file can have many top level classes, but only 1 top level class can be made public, Why so?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38062
    
  22
Do a search and you find this, this, this and doubtless many more, which answer it better than I would have.
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
Originally posted by Abhi vijay:
It is said that a java source file can have many top level classes, but only 1 top level class can be made public, Why so?


One wierd example but it should make the concept clear :

It like that you have ony one father and mother , so there can be only top level class from which you can inherit most of the properties,also father can have a parent class Grandfather hence if you go up the hierarchy you will find only one class.
similarily you will have one parent class from which you can derive most of the properties..

i hope this make clear


<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38062
    
  22
I am afraid you have misunderstood the question, Harshit Rastogi. It said top-level classes, not superclasses.
 
wood burning stoves
 
subject: Top level class?
 
Similar Threads
private and protected modifier in top level class
top-level class
Class modifiers
Roundup game
Top-Level class