wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Inner class access modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inner class access modifiers" Watch "Inner class access modifiers" New topic
Author

Inner class access modifiers

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1164
I understand that inner classes can be declared as public, private or protected.
How is it used? � What�s the difference in access between an inner class that is defined as private versus one which is defined as public?
Thanks,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
this forum isn't for question about Java. It is for questions and comments about JavaRanch. try one of the other forums.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
I'm moving this to Java in General (beginning)


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
The access modifiers act the same as any regular identifier. If your inner-class is public, you can create an instance of the inner-class from any other class outside of the outer-class (with the caveat that since the inner-class is not static, you must first have an instance of the outer-class). If the modifier is private, only the outer-class is able to create an instance of the inner-class, you won't be able to instantiate an object of the inner class elsewhere. Again, you must have an instance of the outer-class to do this.
See http://www.javaranch.com/campfire/StoryInner.jsp for a very nice story on inner classes
Hope this helps,
Jason
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inner class access modifiers
 
Similar Threads
local classes..............
Inner class data access
inner classes
Access Specifier of class: Guidelines to share..
Inner class basics. (Marcus Green's mock exam 2)