In this recipe, you will learn about three types of inner classes:
- Inner class: This is a class defined inside another (enclosing) class. Its accessibility from outside the enclosing class is regulated by the public, protected, and private keywords. It can access the private members of the enclosing class, and the enclosing class can access the private members of its inner class.
- Method-local inner class: This is a class defined inside a method. Its scope is restricted to within the method.
- Anonymous inner class: This is an anonymous class defined during object instantiation.