|
Nested classes are broadly categorized as -
1. Non-static nested classes AKA inner classes
Non static nested classes are further categorized based on where they are declared within a class body.
Member inner class
Local inner Class
Anonymous Inner Class
When you define a class within a class body just like other class members, it is called as the member inner class. When you define a class within a method body or code block, it is called as the local inner class. On the other hand, an anonymous inner class can be defined in any expression within a class body and as its name suggest it does not have a name.
2. Static nested classes
In the following sections, we will discuss all the four types with example.