Skip to main content

When and why to use Nested Classes? [Resolved]

Using Object Oriented Programming we have the power to create a class inside a class (a nested class), but I have never created a nested class in my 4 years of coding experience.
What are nested classes good for?

I know that a class can be marked as private if it is nested and that we can access all private members of that class from the containing class. We could just put the variables as private in the containing class itself.
So why create a nested class?

In which scenarios should nested classes be used or are they more powerful in terms of usage over other techniques?


Question Credit: mayur rathi
Question Reference
Asked June 12, 2019
Posted Under: Programming
10 views
2 Answers

Your Answer