Simply put, Java allows us to define classes inside other classes. Nested classes enable us to logically group classes that are only used in one place, write more readable and maintainable code and increase encapsulation .
Read moreIs inner class important in Java?
Inner classes are a security mechanism in Java . We know a class cannot be associated with the access modifier private, but if we have the class as a member of other class, then the inner class can be made private. And this is also used to access the private members of a class.8 Oca 2018
Read moreIs it a good practice to use inner classes?
Nested Class can be used whenever you want to create more than once instance of the class or whenever you want to make that type more available . Nested Class increases the encapsulations as well as it will lead to more readable and maintainable code.
Read moreWhy are Java inner classes bad?
Now you are clear that inner classes keep reference to outer class .So image scenario where you pass reference of inner class to other outer world class and then reference never gets released to in turn OuterClass is also referenced , hence leak. So this makes using inner classes bad if not used prpperly.
Read more