Forums Register Login

Nested classes

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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".
+Pie Number of slices to send: Send
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.
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 620 times.
Similar Threads
answer please
Reg. Inner class & Nested class
Access specifiers
Nested classes
inner class
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:44:31.