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
posted
0
this forum isn't for question about Java. It is for questions and comments about JavaRanch. try one of the other forums.
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
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.