Nested class in Java With Example
→ class inside a class is called nested class.
→ The Main Purpose of Nested Class make the group classes that belong together which makes your code more readable and maintainable.
Advantage of nested class in java:
- code Optimization
- Easy to understand.
- It can access all the member of outer class including private.
- Nested classes can access all the members (data members and methods) of outer class including private.
- As nested classes are logically grouped classes and interfaces in one place so that it is use to develop more readable and maintainable code.
- Nested classes helps to write optimized code, as it require less code to write.
Types of Nested class in java.