Introduction
Inner classes can use variables and functions from their outer class. This helps keep related code together and makes it easier to work with shared data.
When you want a small helper class to work closely with its outer class data.
When you want to organize code by grouping related classes inside one another.
When the inner class needs to change or read the outer class's properties.
When you want to avoid passing outer class data explicitly to the inner class.
When you want to keep the inner class hidden from other parts of the program.