*
The moose likes Beginning Java and the fly likes Nested classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Nested classes" Watch "Nested classes" New topic
Author

Nested classes

Stephen Adams
Greenhorn

Joined: Mar 18, 2002
Posts: 22
Hi,
This is my first time posting on JavaRanch, great site by the way.
My question is about Nested Classes, I know what they are and how they are created, but why would you used them instead of creating a new SubClass?
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Bruce Eckel has an interesting discussion on inner classes. According to him, inner classes allow you to hide a class that implements an interface.
You can also use an inner class if you want to create a class "on the fly".
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Also, an instance of an inner class would have access to the private members of the enclosing class. An instance of a subclass would not have access to the private members of the superclass instance.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nested classes
 
Similar Threads
Reg. Inner class & Nested class
Nested classes
Access specifiers
answer please
inner class