
What is the significance of Inner Classes and Static Inner Classes? or Why are nested classes used?

Hi Friend,
When a class is defined within another class then such a class is called a nested class.
Inner class is a non static class declared inside another class.Non-static inner class keep the reference of outer class and allow to access member variable of outer class. It helps in defining an interface of a class.
We use nested classes because of the following reasons:
It is a way of logically grouping classes that are only used in one place.
It increases encapsulation.Nested classes can lead to more readable and maintainable code.
For more information, visit the following links:
http://www.roseindia.net/help/java/n/java-nested-class.shtml
http://www.roseindia.net/java/master-java/inner.shtml
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.