File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes WHY cant a class be declared as private? 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 "WHY cant a class be declared as private?" Watch "WHY cant a class be declared as private?" New topic

WHY cant a class be declared as private?

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
hi all,
Why we can give private and protected access controller to inner
classes only? Why not to outer class? Why java is stopping us from
doing that?
i understand that it does not make the class available to the JVM in case we declare it as private.
but then accdg to the access specifiers.. if no specier is mentioned itis taken as "friendly" or default" and this specifier makes it available only to the package and subclasses outside the package..
so how come classes with no specifier run properly where as classes declared as private or protected run smoothly ??
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Please continue discussion at this thread

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: WHY cant a class be declared as private?
It's not a secret anymore!