What is Nested Class In Java?
A nested class in Java is a class defined within another class. It helps logically group classes that are only relevant to the enclosing class while improving encapsulation. There are four types of nested classes: static nested classes, non-static inner classes, local classes (defined within a method), and anonymous classes (defined without a name). Nested classes can access the members (including private members) of the enclosing class, enabling better organization and enhancing readability in complex code structures.